while~0: b=10;n,m=input().split() while int(m,b)>int(n):b-=1 print(b)