n=input() t=[] for _ in[0]*n: s=raw_input() b=max(s) if b.isdigit(): b=int(b)+1 else: b=ord(b)-54 #print int(s,b),b t+=[int(s,b)] print min(t)