import sys sys.setrecursionlimit(10 ** 6) stdin = sys.stdin ni = lambda: int(ns()) na = lambda: list(map(int, stdin.readline().split())) ns = lambda: stdin.readline().strip() ntp = lambda: tuple(map(int, stdin.readline().split())) mod = 10 * 9 + 7 inf = 2 << 60 num = inf n = ni() for _ in range(n): S = ns() T = list(reversed(list(S))) m = 0 for i in range(len(S)): j = ord(T[i]) - 48 m += j * (32 ** i) if m < num: num = m print(num)