import java.util.Scanner;

class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int w;
		if(a<=b){
			w = a;
			a = b;
			b = w;
		}
		while(true){
			if((w=a%b)==0) break;
			a = b;
			b = w;
		}
		System.out.println(b);
	}

} import java.util.Scanner; Scanner java.util class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int w;
		if(a<=b){
			w = a;
			a = b;
			b = w;
		}
		while(true){
			if((w=a%b)==0) break;
			a = b;
			b = w;
		}
		System.out.println(b);
	}

} Main public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int w;
		if(a<=b){
			w = a;
			a = b;
			b = w;
		}
		while(true){
			if((w=a%b)==0) break;
			a = b;
			b = w;
		}
		System.out.println(b);
	} main {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int w;
		if(a<=b){
			w = a;
			a = b;
			b = w;
		}
		while(true){
			if((w=a%b)==0) break;
			a = b;
			b = w;
		}
		System.out.println(b);
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int a = sc.nextInt(); a sc.nextInt() sc.nextInt sc int b = sc.nextInt(); b sc.nextInt() sc.nextInt sc int w; w if(a<=b){
			w = a;
			a = b;
			b = w;
		} a<=b a b {
			w = a;
			a = b;
			b = w;
		} w = a w a a = b a b b = w b w while(true){
			if((w=a%b)==0) break;
			a = b;
			b = w;
		} true {
			if((w=a%b)==0) break;
			a = b;
			b = w;
		} if((w=a%b)==0) break; (w=a%b)==0 (w=a%b) w a%b a b 0 break; a = b a b b = w b w System.out.println(b) System.out.println System.out System System.out b String[] args args
import java.util.Scanner;

class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int w;
		if(a<=b){
			w = a;
			a = b;
			b = w;
		}
		while(true){
			if((w=a%b)==0) break;
			a = b;
			b = w;
		}
		System.out.println(b);
	}

}