import java.util.Scanner;
public class Main {
	public static void calcu(int a,int b){
		int ans=a;
		while(b!=0){
			ans = a % b; 
			a = b; 
			b = ans; 
		}
		System.out.println(a);
	}
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int a = scan.nextInt();
		int b = scan.nextInt();
		if(a>b)
			calcu(a,b);
		else
			calcu(b,a);
	}

} import java.util.Scanner; Scanner java.util public class Main {
	public static void calcu(int a,int b){
		int ans=a;
		while(b!=0){
			ans = a % b; 
			a = b; 
			b = ans; 
		}
		System.out.println(a);
	}
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int a = scan.nextInt();
		int b = scan.nextInt();
		if(a>b)
			calcu(a,b);
		else
			calcu(b,a);
	}

} Main public static void calcu(int a,int b){
		int ans=a;
		while(b!=0){
			ans = a % b; 
			a = b; 
			b = ans; 
		}
		System.out.println(a);
	} calcu {
		int ans=a;
		while(b!=0){
			ans = a % b; 
			a = b; 
			b = ans; 
		}
		System.out.println(a);
	} int ans=a; ans a while(b!=0){
			ans = a % b; 
			a = b; 
			b = ans; 
		} b!=0 b 0 {
			ans = a % b; 
			a = b; 
			b = ans; 
		} ans = a % b ans a % b a b a = b a b b = ans b ans System.out.println(a) System.out.println System.out System System.out a 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();
		if(a>b)
			calcu(a,b);
		else
			calcu(b,a);
	} main {
		Scanner scan = new Scanner(System.in);
		int a = scan.nextInt();
		int b = scan.nextInt();
		if(a>b)
			calcu(a,b);
		else
			calcu(b,a);
	} 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 if(a>b)
			calcu(a,b);
		else
			calcu(b,a); a>b a b calcu(a,b) calcu a b calcu(b,a) calcu b a String[] args args public class Main {
	public static void calcu(int a,int b){
		int ans=a;
		while(b!=0){
			ans = a % b; 
			a = b; 
			b = ans; 
		}
		System.out.println(a);
	}
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int a = scan.nextInt();
		int b = scan.nextInt();
		if(a>b)
			calcu(a,b);
		else
			calcu(b,a);
	}

} public class Main {
	public static void calcu(int a,int b){
		int ans=a;
		while(b!=0){
			ans = a % b; 
			a = b; 
			b = ans; 
		}
		System.out.println(a);
	}
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int a = scan.nextInt();
		int b = scan.nextInt();
		if(a>b)
			calcu(a,b);
		else
			calcu(b,a);
	}

} Main
import java.util.Scanner;
public class Main {
	public static void calcu(int a,int b){
		int ans=a;
		while(b!=0){
			ans = a % b; 
			a = b; 
			b = ans; 
		}
		System.out.println(a);
	}
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int a = scan.nextInt();
		int b = scan.nextInt();
		if(a>b)
			calcu(a,b);
		else
			calcu(b,a);
	}

}