import sys #sys.setrecursionlimit(n) import heapq import re import bisect import random import math import itertools from collections import defaultdict, deque from fractions import Fraction from copy import deepcopy a = int(input()) b = int(input()) c = Fraction(a, b) aa = c.numerator bb = c.denominator d = bb p2 = 0 p5 = 0 while(d % 2 == 0): d //= 2 p2 += 1 while(d % 5 == 0): d //= 5 p5 += 1 if d == 1: while(aa % 10 == 0): aa //= 10 aa %= 10 while(p2 > p5): aa = (aa * 5) % 10 p5 += 1 while(p5 > p2): aa = (aa * 2) % 10 p2 += 1 print(aa) else: print(-1)