import java.util.*; public class Main { public static void main (String[] args) { Scanner sc = new Scanner(System.in); long a = sc.nextLong(); long b = sc.nextLong(); long c = a + b; HashMap map = new HashMap<>(); long ans = 1; for (long i = 2; i <= Math.sqrt(c); i++) { while (c % i == 0) { if (a % i == 0) { ans *= i; a /= i; } else if (b % i == 0) { ans *= i; b /= i; } c /= i; } } if (a % c == 0) { ans *= c; } else if (b % c == 0) { ans += c; } System.out.println(ans); } }