N = input() #numbering = -1 smallest = 'Z' * 12 for loop in xrange(N): S = raw_input() #numbering = max(max(S), numbering) if len(S) == len(smallest): smallest = min(S, smallest) elif len(S) < len(smallest): smallest = S #print S, numbering, smallest base = 36 while True: try: int(smallest, base) base -= 1 except: base += 1 print int(smallest, base) break