N = int(input()) M = int(input()) X2 = 0 M2 = M while M2 % 2 == 0: M2 //= 2 while M2 % 5 == 0: M2 //= 5 if M2 != 1: print(-1) exit() S = str(N*10**18/M) for s in reversed(S): if s != "0" and s != ".": print(s) exit()