import java.util.Scanner;
public class Main {
public static void main(String[] args) {
int m;
int n;
int a=1;
int b;
Scanner in=new Scanner(System.in);
m=in.nextInt();
n=in.nextInt();
while(m!=n) {
b=Math.max(m, n);
m=Math.min(m, n);
n=b;
b=n-m;
n=m;
m=b;
}
System.out.println(n);
}
}