import java.util.Arrays; import java.util.HashSet; import java.util.LinkedList; import java.util.Scanner; import java.util.Set; public class Main { public static long gcd(long a, long b){ return b == 0 ? a : gcd(b, a % b); } public static void main(String[] args) { Scanner sc = new Scanner(System.in); final long A = sc.nextLong(); final long B = sc.nextLong(); System.out.println(gcd(gcd(A + B, A), gcd(A + B, B))); } }