while~0: b=10;n,m=raw_input().split() while`int(m,b)`!=n:b-=1 print b