import java.io.*; import java.util.*; public class Main { public static void main(String[] args) throws Exception { Scanner sc = new Scanner(); long a = sc.nextLong(); long b = sc.nextLong(); long c = a + b; long gcdA = getGCD(a, c); long gcdB = getGCD(b, c); HashSet each = new HashSet<>(); for (long i = 2; i <= Math.sqrt(gcdA); i++) { while (gcdA % i == 0) { each.add(i); gcdA /= i; } } if (gcdA > 1) { each.add(gcdA); } for (long i = 2; i <= Math.sqrt(gcdB); i++) { while (gcdB % i == 0) { each.add(i); gcdB /= i; } } if (gcdB > 1) { each.add(gcdB); } long ans = 1; for (long x : each) { int times = Math.min(getCount(c, x), getCount(a, x) + getCount(b, x)); for (int i = 0; i < times; i++) { ans *= x; } } System.out.println(ans); } static int getCount(long base, long x) { int count = 0; while (base % x == 0) { count++; base /= x; } return count; } static long getGCD(long x, long y) { if (y == 0) { return x; } else { return getGCD(y, x % y); } } } class Scanner { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer st = new StringTokenizer(""); public Scanner() throws Exception { } public int nextInt() throws Exception { return Integer.parseInt(next()); } public long nextLong() throws Exception { return Long.parseLong(next()); } public double nextDouble() throws Exception { return Double.parseDouble(next()); } public String next() throws Exception { while (!st.hasMoreTokens()) { st = new StringTokenizer(br.readLine()); } return st.nextToken(); } }