import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner input=new Scanner(System.in);
		int a=input.nextInt();
		int b=input.nextInt();
		System.out.println(gcd(a,b));
	}
	
	public static int gcd(int a,int b){
		return b==0 ? a : gcd(b,a%b);
	}

} import java.util.*; util.* java public class Main {
	public static void main(String[] args){
		Scanner input=new Scanner(System.in);
		int a=input.nextInt();
		int b=input.nextInt();
		System.out.println(gcd(a,b));
	}
	
	public static int gcd(int a,int b){
		return b==0 ? a : gcd(b,a%b);
	}

} Main public static void main(String[] args){
		Scanner input=new Scanner(System.in);
		int a=input.nextInt();
		int b=input.nextInt();
		System.out.println(gcd(a,b));
	} main {
		Scanner input=new Scanner(System.in);
		int a=input.nextInt();
		int b=input.nextInt();
		System.out.println(gcd(a,b));
	} Scanner input=new Scanner(System.in); input new Scanner(System.in) int a=input.nextInt(); a input.nextInt() input.nextInt input int b=input.nextInt(); b input.nextInt() input.nextInt input System.out.println(gcd(a,b)) System.out.println System.out System System.out gcd(a,b) gcd a b String[] args args public static int gcd(int a,int b){
		return b==0 ? a : gcd(b,a%b);
	} gcd {
		return b==0 ? a : gcd(b,a%b);
	} return b==0 ? a : gcd(b,a%b); b==0 ? a : gcd(b,a%b) b==0 b 0 a gcd(b,a%b) gcd b a%b a b int a a int b b public class Main {
	public static void main(String[] args){
		Scanner input=new Scanner(System.in);
		int a=input.nextInt();
		int b=input.nextInt();
		System.out.println(gcd(a,b));
	}
	
	public static int gcd(int a,int b){
		return b==0 ? a : gcd(b,a%b);
	}

} public class Main {
	public static void main(String[] args){
		Scanner input=new Scanner(System.in);
		int a=input.nextInt();
		int b=input.nextInt();
		System.out.println(gcd(a,b));
	}
	
	public static int gcd(int a,int b){
		return b==0 ? a : gcd(b,a%b);
	}

} Main
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner input=new Scanner(System.in);
		int a=input.nextInt();
		int b=input.nextInt();
		System.out.println(gcd(a,b));
	}
	
	public static int gcd(int a,int b){
		return b==0 ? a : gcd(b,a%b);
	}

}