n=input() m=input() o=n*1./m s="{0:.49f}".format(o) if s[-1]=="0": print s.rstrip("0")[-1] else: print -1