from decimal import * def F(n): while n%2==0:n//=2 while n%5==0:n//=5 return n == 1 getcontext().prec=1000 n,m=Decimal(input()),Decimal(input()) x=str(n/m) if 'E' in x:x=x[:x.index('E')] if F(m): for x in x[::-1]: if x not in['0','.'] :print(x);break else:print(-1)