import java.util.*;

public class Main {
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		int x=sc.nextInt();
		int y=sc.nextInt();
		System.out.println(gcd(x,y));
	}
	static int gcd(int a,int b){
		int t=0;
		while(true){
			if(b==0){
				break;
			}else{
				t=a%b;
				a=b;
				b=t;
				gcd(a,b);
			}
		}
		return a;
	}
} import java.util.*; util.* java public class Main {
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		int x=sc.nextInt();
		int y=sc.nextInt();
		System.out.println(gcd(x,y));
	}
	static int gcd(int a,int b){
		int t=0;
		while(true){
			if(b==0){
				break;
			}else{
				t=a%b;
				a=b;
				b=t;
				gcd(a,b);
			}
		}
		return a;
	}
} Main public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		int x=sc.nextInt();
		int y=sc.nextInt();
		System.out.println(gcd(x,y));
	} main {
		Scanner sc=new Scanner(System.in);
		int x=sc.nextInt();
		int y=sc.nextInt();
		System.out.println(gcd(x,y));
	} Scanner sc=new Scanner(System.in); sc new Scanner(System.in) int x=sc.nextInt(); x sc.nextInt() sc.nextInt sc int y=sc.nextInt(); y sc.nextInt() sc.nextInt sc System.out.println(gcd(x,y)) System.out.println System.out System System.out gcd(x,y) gcd x y String[] args args static int gcd(int a,int b){
		int t=0;
		while(true){
			if(b==0){
				break;
			}else{
				t=a%b;
				a=b;
				b=t;
				gcd(a,b);
			}
		}
		return a;
	} gcd {
		int t=0;
		while(true){
			if(b==0){
				break;
			}else{
				t=a%b;
				a=b;
				b=t;
				gcd(a,b);
			}
		}
		return a;
	} int t=0; t 0 while(true){
			if(b==0){
				break;
			}else{
				t=a%b;
				a=b;
				b=t;
				gcd(a,b);
			}
		} true {
			if(b==0){
				break;
			}else{
				t=a%b;
				a=b;
				b=t;
				gcd(a,b);
			}
		} if(b==0){
				break;
			}else{
				t=a%b;
				a=b;
				b=t;
				gcd(a,b);
			} b==0 b 0 {
				break;
			} break; {
				t=a%b;
				a=b;
				b=t;
				gcd(a,b);
			} t=a%b t a%b a b a=b a b b=t b t gcd(a,b) gcd a b return a; a int a a int b b public class Main {
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		int x=sc.nextInt();
		int y=sc.nextInt();
		System.out.println(gcd(x,y));
	}
	static int gcd(int a,int b){
		int t=0;
		while(true){
			if(b==0){
				break;
			}else{
				t=a%b;
				a=b;
				b=t;
				gcd(a,b);
			}
		}
		return a;
	}
} public class Main {
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		int x=sc.nextInt();
		int y=sc.nextInt();
		System.out.println(gcd(x,y));
	}
	static int gcd(int a,int b){
		int t=0;
		while(true){
			if(b==0){
				break;
			}else{
				t=a%b;
				a=b;
				b=t;
				gcd(a,b);
			}
		}
		return a;
	}
} Main
import java.util.*;

public class Main {
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		int x=sc.nextInt();
		int y=sc.nextInt();
		System.out.println(gcd(x,y));
	}
	static int gcd(int a,int b){
		int t=0;
		while(true){
			if(b==0){
				break;
			}else{
				t=a%b;
				a=b;
				b=t;
				gcd(a,b);
			}
		}
		return a;
	}
}