import java.util.Scanner;
public class Main {
	static int gcd(int a,int b){
		if(b==0){
			return a;
		}else{
			return gcd(b,a%b);
		}
	}
	public static void main(String[] args){
		Scanner scan=new Scanner(System.in);
		int a=scan.nextInt();
		int b=scan.nextInt();
		System.out.println(gcd(Math.max(a,b),Math.min(a,b)));
		scan.close();
	}
} import java.util.Scanner; Scanner java.util public class Main {
	static int gcd(int a,int b){
		if(b==0){
			return a;
		}else{
			return gcd(b,a%b);
		}
	}
	public static void main(String[] args){
		Scanner scan=new Scanner(System.in);
		int a=scan.nextInt();
		int b=scan.nextInt();
		System.out.println(gcd(Math.max(a,b),Math.min(a,b)));
		scan.close();
	}
} Main static int gcd(int a,int b){
		if(b==0){
			return a;
		}else{
			return gcd(b,a%b);
		}
	} gcd {
		if(b==0){
			return a;
		}else{
			return gcd(b,a%b);
		}
	} if(b==0){
			return a;
		}else{
			return gcd(b,a%b);
		} b==0 b 0 {
			return a;
		} return a; a {
			return gcd(b,a%b);
		} return gcd(b,a%b); gcd(b,a%b) gcd b a%b a b int a a int b b public static void main(String[] args){
		Scanner scan=new Scanner(System.in);
		int a=scan.nextInt();
		int b=scan.nextInt();
		System.out.println(gcd(Math.max(a,b),Math.min(a,b)));
		scan.close();
	} main {
		Scanner scan=new Scanner(System.in);
		int a=scan.nextInt();
		int b=scan.nextInt();
		System.out.println(gcd(Math.max(a,b),Math.min(a,b)));
		scan.close();
	} Scanner scan=new Scanner(System.in); scan new Scanner(System.in) int a=scan.nextInt(); a scan.nextInt() scan.nextInt scan int b=scan.nextInt(); b scan.nextInt() scan.nextInt scan System.out.println(gcd(Math.max(a,b),Math.min(a,b))) System.out.println System.out System System.out gcd(Math.max(a,b),Math.min(a,b)) gcd Math.max(a,b) Math.max Math a b Math.min(a,b) Math.min Math a b scan.close() scan.close scan String[] args args public class Main {
	static int gcd(int a,int b){
		if(b==0){
			return a;
		}else{
			return gcd(b,a%b);
		}
	}
	public static void main(String[] args){
		Scanner scan=new Scanner(System.in);
		int a=scan.nextInt();
		int b=scan.nextInt();
		System.out.println(gcd(Math.max(a,b),Math.min(a,b)));
		scan.close();
	}
} public class Main {
	static int gcd(int a,int b){
		if(b==0){
			return a;
		}else{
			return gcd(b,a%b);
		}
	}
	public static void main(String[] args){
		Scanner scan=new Scanner(System.in);
		int a=scan.nextInt();
		int b=scan.nextInt();
		System.out.println(gcd(Math.max(a,b),Math.min(a,b)));
		scan.close();
	}
} Main
import java.util.Scanner;
public class Main {
	static int gcd(int a,int b){
		if(b==0){
			return a;
		}else{
			return gcd(b,a%b);
		}
	}
	public static void main(String[] args){
		Scanner scan=new Scanner(System.in);
		int a=scan.nextInt();
		int b=scan.nextInt();
		System.out.println(gcd(Math.max(a,b),Math.min(a,b)));
		scan.close();
	}
}