import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner scan = new Scanner(System.in); int N = scan.nextInt(); String[] V = new String[N]; for(int i = 0; i < N; i++) { V[i] = scan.next(); } scan.close(); // 'A' = 65, '1' = 49 long min = Long.MAX_VALUE; for(int i = 0; i < N; i++) { String s = V[i]; int max = 0; for(int j = 0; j < s.length(); j++) { char c = s.charAt(j); if(max < (int)c) { max = (int)c; } //System.out.println((int)c); } if(max <= 58) { max = 1 + max - 48; }else { max = 10 + max - 64; //System.out.println(max); } //System.out.println(max); for(int j = max; j <= 36; j++) { long num = Long.parseLong(Long.toString(Long.parseLong(s, j), 10)); //System.out.println(num); if(min > num) { min = num; } } } System.out.println(min); } }