import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int n=Integer.valueOf(sc.next());
		int m=Integer.valueOf(sc.next());
		if(n==m){
			System.out.println(n);
			return;
		}else if(n>m){
			int temp=m;
			m=n;
			n=temp;
		}
		while(n!=0){
			m%=n;
			if(m==0){
				System.out.println(n);
				return;
			}
			n%=m;
		}
		System.out.println(m);
	}

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

	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int n=Integer.valueOf(sc.next());
		int m=Integer.valueOf(sc.next());
		if(n==m){
			System.out.println(n);
			return;
		}else if(n>m){
			int temp=m;
			m=n;
			n=temp;
		}
		while(n!=0){
			m%=n;
			if(m==0){
				System.out.println(n);
				return;
			}
			n%=m;
		}
		System.out.println(m);
	}

} Main public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int n=Integer.valueOf(sc.next());
		int m=Integer.valueOf(sc.next());
		if(n==m){
			System.out.println(n);
			return;
		}else if(n>m){
			int temp=m;
			m=n;
			n=temp;
		}
		while(n!=0){
			m%=n;
			if(m==0){
				System.out.println(n);
				return;
			}
			n%=m;
		}
		System.out.println(m);
	} main {
		Scanner sc=new Scanner(System.in);
		int n=Integer.valueOf(sc.next());
		int m=Integer.valueOf(sc.next());
		if(n==m){
			System.out.println(n);
			return;
		}else if(n>m){
			int temp=m;
			m=n;
			n=temp;
		}
		while(n!=0){
			m%=n;
			if(m==0){
				System.out.println(n);
				return;
			}
			n%=m;
		}
		System.out.println(m);
	} Scanner sc=new Scanner(System.in); sc new Scanner(System.in) int n=Integer.valueOf(sc.next()); n Integer.valueOf(sc.next()) Integer.valueOf Integer sc.next() sc.next sc int m=Integer.valueOf(sc.next()); m Integer.valueOf(sc.next()) Integer.valueOf Integer sc.next() sc.next sc if(n==m){
			System.out.println(n);
			return;
		}else if(n>m){
			int temp=m;
			m=n;
			n=temp;
		} n==m n m {
			System.out.println(n);
			return;
		} System.out.println(n) System.out.println System.out System System.out n return; if(n>m){
			int temp=m;
			m=n;
			n=temp;
		} n>m n m {
			int temp=m;
			m=n;
			n=temp;
		} int temp=m; temp m m=n m n n=temp n temp while(n!=0){
			m%=n;
			if(m==0){
				System.out.println(n);
				return;
			}
			n%=m;
		} n!=0 n 0 {
			m%=n;
			if(m==0){
				System.out.println(n);
				return;
			}
			n%=m;
		} m%=n m n if(m==0){
				System.out.println(n);
				return;
			} m==0 m 0 {
				System.out.println(n);
				return;
			} System.out.println(n) System.out.println System.out System System.out n return; n%=m n m 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 sc=new Scanner(System.in);
		int n=Integer.valueOf(sc.next());
		int m=Integer.valueOf(sc.next());
		if(n==m){
			System.out.println(n);
			return;
		}else if(n>m){
			int temp=m;
			m=n;
			n=temp;
		}
		while(n!=0){
			m%=n;
			if(m==0){
				System.out.println(n);
				return;
			}
			n%=m;
		}
		System.out.println(m);
	}

} public class Main {

	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int n=Integer.valueOf(sc.next());
		int m=Integer.valueOf(sc.next());
		if(n==m){
			System.out.println(n);
			return;
		}else if(n>m){
			int temp=m;
			m=n;
			n=temp;
		}
		while(n!=0){
			m%=n;
			if(m==0){
				System.out.println(n);
				return;
			}
			n%=m;
		}
		System.out.println(m);
	}

} Main
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int n=Integer.valueOf(sc.next());
		int m=Integer.valueOf(sc.next());
		if(n==m){
			System.out.println(n);
			return;
		}else if(n>m){
			int temp=m;
			m=n;
			n=temp;
		}
		while(n!=0){
			m%=n;
			if(m==0){
				System.out.println(n);
				return;
			}
			n%=m;
		}
		System.out.println(m);
	}

}