import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner cin=new Scanner(System.in);
		
		int x=cin.nextInt(),y=cin.nextInt();
		int m=x,n=y,k=x*y;
		
		while(k!=0) {
			 k=m%n;
			 m=n;n=k;
		}
		System.out.println(m);
	}

}
 import java.util.*; util.* java public class Main {

	public static void main(String[] args) {
		Scanner cin=new Scanner(System.in);
		
		int x=cin.nextInt(),y=cin.nextInt();
		int m=x,n=y,k=x*y;
		
		while(k!=0) {
			 k=m%n;
			 m=n;n=k;
		}
		System.out.println(m);
	}

} Main public static void main(String[] args) {
		Scanner cin=new Scanner(System.in);
		
		int x=cin.nextInt(),y=cin.nextInt();
		int m=x,n=y,k=x*y;
		
		while(k!=0) {
			 k=m%n;
			 m=n;n=k;
		}
		System.out.println(m);
	} main {
		Scanner cin=new Scanner(System.in);
		
		int x=cin.nextInt(),y=cin.nextInt();
		int m=x,n=y,k=x*y;
		
		while(k!=0) {
			 k=m%n;
			 m=n;n=k;
		}
		System.out.println(m);
	} Scanner cin=new Scanner(System.in); cin new Scanner(System.in) int x=cin.nextInt() x cin.nextInt() cin.nextInt cin y=cin.nextInt(); y cin.nextInt() cin.nextInt cin int m=x m x n=y n y k=x*y; k x*y x y while(k!=0) {
			 k=m%n;
			 m=n;n=k;
		} k!=0 k 0 {
			 k=m%n;
			 m=n;n=k;
		} k=m%n k m%n m n m=n m n n=k n k System.out.println(m) System.out.println System.out System System.out m String[] args args public class Main {

	public static void main(String[] args) {
		Scanner cin=new Scanner(System.in);
		
		int x=cin.nextInt(),y=cin.nextInt();
		int m=x,n=y,k=x*y;
		
		while(k!=0) {
			 k=m%n;
			 m=n;n=k;
		}
		System.out.println(m);
	}

} public class Main {

	public static void main(String[] args) {
		Scanner cin=new Scanner(System.in);
		
		int x=cin.nextInt(),y=cin.nextInt();
		int m=x,n=y,k=x*y;
		
		while(k!=0) {
			 k=m%n;
			 m=n;n=k;
		}
		System.out.println(m);
	}

} Main
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner cin=new Scanner(System.in);
		
		int x=cin.nextInt(),y=cin.nextInt();
		int m=x,n=y,k=x*y;
		
		while(k!=0) {
			 k=m%n;
			 m=n;n=k;
		}
		System.out.println(m);
	}

}

