import java.math.BigDecimal; import java.util.Scanner; class Main { static long gcd(long a, long b) { return b != 0 ? gcd(b, a % b) : a; } public static void main(String[] args) { Scanner sc = new Scanner(System.in); long N = sc.nextLong(), M = sc.nextLong(); sc.close(); long tmp1 = gcd(N, M); N /= tmp1; M /= tmp1; tmp1 = M; while (tmp1 % 2 == 0) tmp1 /= 2; while (tmp1 % 5 == 0) tmp1 /= 5; if (tmp1 == 1) { BigDecimal tmp2 = new BigDecimal(N), tmp3 = new BigDecimal(M); String tmp4 = tmp2.divide(tmp3).toPlainString(); int i = tmp4.length() - 1; while (tmp4.charAt(i) == '0') --i; System.out.print(tmp4.charAt(i)); } else System.out.print(-1); } }