/* package whatever; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
class Ideone
{
	static String longest(String s) {
    int i = 0;
    int longestStart = 0;
    int longestEnd = 0;
    while (i < s.length()) {
      // Skip past all the digits.
      while (i < s.length() && Character.isDigit(s.charAt(i))) {
        ++i;
      }

      // i now points to the start of a substring
      // or one past the end of the string.
      int start = i;

      // Keep a flag to record if there is an uppercase character.
      boolean hasUppercase = false;

      // Increment i until you hit another digit or the end of the string.
      while (i < s.length() && !Character.isDigit(s.charAt(i))) {
        hasUppercase |= Character.isUpperCase(s.charAt(i));
        ++i;
      }

      // Check if this is longer than the longest so far.
      if (hasUppercase && i - start > longestEnd - longestStart) {
        longestEnd = i;
        longestStart = start;
      }
    }
    return s.substring(longestStart, longestEnd);
	}
	public static void main (String[] args) throws java.lang.Exception
	{
		System.out.println(longest("a0Ba"));
	}
}