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