import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); long aa = sc.nextLong(); long bb = sc.nextLong(); long c = aa + bb; long a = gcd(aa + bb, aa); long b = gcd(aa + bb, bb); HashSet set = new HashSet<>(); for (long i = 2; i <= Math.sqrt(a); i++) { while (a % i == 0) { set.add(i); a /= i; } } if (a != 1) { set.add(a); } for (long i = 2; i <= Math.sqrt(b); i++) { while (b % i == 0) { set.add(i); b /= i; } } if (b != 1) { set.add(b); } HashMap mapX = new HashMap<>(); for (long x : set) { int idx = 0; while (c % x == 0) { idx++; c /= x; } mapX.put(x, idx); } HashMap mapY = new HashMap<>(); for (long x : set) { int idx = 0; while (aa % x == 0) { idx++; aa /= x; } while (bb % x == 0) { idx++; bb /= x; } mapY.put(x, idx); } long ans = 1; for (Map.Entry entry : mapX.entrySet()) { if (mapY.containsKey(entry.getKey())) { ans *= (long)(Math.pow(entry.getKey(), Math.min(entry.getValue(), mapY.get(entry.getKey())))); } } System.out.println(ans); } static long gcd(long x, long y) { if (x % y == 0) { return y; } else { return gcd(y, x % y); } } }