import java.util.*;
 
public class Main {
	
	
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n1= sc.nextInt();
		int n2=sc.nextInt();
		cout(gcd(n1,n2));
	}
	
	public static int gcd(int a,int b){
		if(a%b==0) return b;
		else return gcd(b,a%b);
	}
	
	public static void showary(int[] ary){
		for(int i=0;i<ary.length-1;i++){
			System.out.print(ary[i]+" ");
		}
		cout(ary[ary.length-1]);
	}
	
	public static void cout(String n){
		System.out.println(n);
	}
	
	public static void cout(int n){
		System.out.println(n);
	}
} import java.util.*; util.* java public class Main {
	
	
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n1= sc.nextInt();
		int n2=sc.nextInt();
		cout(gcd(n1,n2));
	}
	
	public static int gcd(int a,int b){
		if(a%b==0) return b;
		else return gcd(b,a%b);
	}
	
	public static void showary(int[] ary){
		for(int i=0;i<ary.length-1;i++){
			System.out.print(ary[i]+" ");
		}
		cout(ary[ary.length-1]);
	}
	
	public static void cout(String n){
		System.out.println(n);
	}
	
	public static void cout(int n){
		System.out.println(n);
	}
} Main public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n1= sc.nextInt();
		int n2=sc.nextInt();
		cout(gcd(n1,n2));
	} main {
		Scanner sc = new Scanner(System.in);
		int n1= sc.nextInt();
		int n2=sc.nextInt();
		cout(gcd(n1,n2));
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int n1= sc.nextInt(); n1 sc.nextInt() sc.nextInt sc int n2=sc.nextInt(); n2 sc.nextInt() sc.nextInt sc cout(gcd(n1,n2)) cout gcd(n1,n2) gcd n1 n2 String[] args args public static int gcd(int a,int b){
		if(a%b==0) return b;
		else return gcd(b,a%b);
	} gcd {
		if(a%b==0) return b;
		else return gcd(b,a%b);
	} if(a%b==0) return b;
		else return gcd(b,a%b); a%b==0 a%b a b 0 return b; 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 showary(int[] ary){
		for(int i=0;i<ary.length-1;i++){
			System.out.print(ary[i]+" ");
		}
		cout(ary[ary.length-1]);
	} showary {
		for(int i=0;i<ary.length-1;i++){
			System.out.print(ary[i]+" ");
		}
		cout(ary[ary.length-1]);
	} for(int i=0;i<ary.length-1;i++){
			System.out.print(ary[i]+" ");
		} int i=0; int i=0; i 0 i<ary.length-1 i ary.length-1 ary.length ary ary.length 1 i++ i++ i {
			System.out.print(ary[i]+" ");
		} {
			System.out.print(ary[i]+" ");
		} System.out.print(ary[i]+" ") System.out.print System.out System System.out ary[i]+" " ary[i] ary i " " cout(ary[ary.length-1]) cout ary[ary.length-1] ary ary.length-1 ary.length ary ary.length 1 int[] ary ary public static void cout(String n){
		System.out.println(n);
	} cout {
		System.out.println(n);
	} System.out.println(n) System.out.println System.out System System.out n String n n public static void cout(int n){
		System.out.println(n);
	} cout {
		System.out.println(n);
	} System.out.println(n) System.out.println System.out System System.out n int n n public class Main {
	
	
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n1= sc.nextInt();
		int n2=sc.nextInt();
		cout(gcd(n1,n2));
	}
	
	public static int gcd(int a,int b){
		if(a%b==0) return b;
		else return gcd(b,a%b);
	}
	
	public static void showary(int[] ary){
		for(int i=0;i<ary.length-1;i++){
			System.out.print(ary[i]+" ");
		}
		cout(ary[ary.length-1]);
	}
	
	public static void cout(String n){
		System.out.println(n);
	}
	
	public static void cout(int n){
		System.out.println(n);
	}
} public class Main {
	
	
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n1= sc.nextInt();
		int n2=sc.nextInt();
		cout(gcd(n1,n2));
	}
	
	public static int gcd(int a,int b){
		if(a%b==0) return b;
		else return gcd(b,a%b);
	}
	
	public static void showary(int[] ary){
		for(int i=0;i<ary.length-1;i++){
			System.out.print(ary[i]+" ");
		}
		cout(ary[ary.length-1]);
	}
	
	public static void cout(String n){
		System.out.println(n);
	}
	
	public static void cout(int n){
		System.out.println(n);
	}
} Main
import java.util.*;
 
public class Main {
	
	
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n1= sc.nextInt();
		int n2=sc.nextInt();
		cout(gcd(n1,n2));
	}
	
	public static int gcd(int a,int b){
		if(a%b==0) return b;
		else return gcd(b,a%b);
	}
	
	public static void showary(int[] ary){
		for(int i=0;i<ary.length-1;i++){
			System.out.print(ary[i]+" ");
		}
		cout(ary[ary.length-1]);
	}
	
	public static void cout(String n){
		System.out.println(n);
	}
	
	public static void cout(int n){
		System.out.println(n);
	}
}