import java.util.HashMap; import java.util.Map; import java.util.NoSuchElementException; import java.util.Scanner; public class Main { public static void main(String[] args) throws Exception { Scanner sc = new Scanner(System.in); int x = sc.nextInt(); int y = sc.nextInt(); Map mapx = bunkai(x); int x2 = mapx.getOrDefault(2, 0); int x5 = mapx.getOrDefault(5, 0); Map mapy = bunkai(y); int y2 = mapy.getOrDefault(2, 0); int y5 = mapy.getOrDefault(5, 0); for (int i = 0; i < 35; i++) { if ((x2 + x5 - y2 - y5) % 2 == 0) { if (x5 < y5) { x5++; } else if (x2 < 7) { x2++; } else { x5++; } } else if (x5 < y5) { x5++; } else if (x2 < y2) { x2++; } else { if (x2 - y2 > x5 - y5) { x2--; } else { x5--; } } x = calc(x2, x5); System.out.println(x); if (x == y) { break; } mapx = bunkai(x); x2 = mapx.getOrDefault(2, 0); x5 = mapx.getOrDefault(5, 0); try { y = sc.nextInt(); } catch (NoSuchElementException e) { break; } if (x == y) { break; } mapy = bunkai(y); y2 = mapy.getOrDefault(2, 0); y5 = mapy.getOrDefault(5, 0); } sc.close(); } static int calc(int x2, int x5) { return Math.min(power(2, x2) * power(5, x5), 1000000000); } static int power(int x, int n) { if (n == 0) { return 1; } int val = power(x, n / 2); val = val * val; if (n % 2 == 1) { val = val * x; } return val; } static Map bunkai(int n) { Map soinsu = new HashMap<>(); int end = (int) Math.sqrt(n); int d = 2; while (n > 1) { if (n % d == 0) { n /= d; if (soinsu.containsKey(d)) { soinsu.put(d, soinsu.get(d) + 1); } else { soinsu.put(d, 1); } end = (int) Math.sqrt(n); } else { if (d > end) { d = n - 1; } d++; } } return soinsu; } }