N = int(input()) ans = float('inf') for _ in range(N): V = input() b = int(max(V), 36) + 1 ans = min(ans, int(V, b)) print(ans)