while 1: a=10;b,c=input().split() while int(c,a)-int(b):a-=1 print(a)