N = int(raw_input()) M = int(raw_input()) m = M while m%2 == 0: m /= 2 while m%5 == 0: m /= 5 if m == 1: a = 10**100/M*N while a%10 == 0: a /= 10 print str(a)[-1] else: print -1