import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); long n = sc.nextLong(); long m = sc.nextLong(); long gcd = getGCD(n, m); n /= gcd; m /= gcd; long x = m; int twoCount = 0; while (x % 2 == 0){ x /= 2; twoCount++; } int fiveCount = 0; while (x % 5 == 0) { x /= 5; fiveCount++; } if (x != 1) { System.out.println(-1); return; } while (n % 10 == 0) { n /= 10; } n %= 10; if (twoCount > fiveCount) { System.out.println(5); } else { fiveCount -= twoCount; for (int i = 0; i < fiveCount; i++) { n *= 10; n /= 5; n %= 10; } System.out.println(n); } } static long getGCD(long x, long y) { if (x % y == 0) { return y; } else { return getGCD(y, x % y); } } }