import java.util.Scanner;

class Main {
	public static int gcd(int n1, int n2){
			if (n1 < n2) return gcd(n2,n1);
			if (n2 == 0) return n1;
			if (n1 == n2) return n1;
			return gcd(n2, n1%n2);
		}
	
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		
		System.out.println(gcd(a,b));
		
	}
}
 import java.util.Scanner; Scanner java.util class Main {
	public static int gcd(int n1, int n2){
			if (n1 < n2) return gcd(n2,n1);
			if (n2 == 0) return n1;
			if (n1 == n2) return n1;
			return gcd(n2, n1%n2);
		}
	
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		
		System.out.println(gcd(a,b));
		
	}
} Main public static int gcd(int n1, int n2){
			if (n1 < n2) return gcd(n2,n1);
			if (n2 == 0) return n1;
			if (n1 == n2) return n1;
			return gcd(n2, n1%n2);
		} gcd {
			if (n1 < n2) return gcd(n2,n1);
			if (n2 == 0) return n1;
			if (n1 == n2) return n1;
			return gcd(n2, n1%n2);
		} if (n1 < n2) return gcd(n2,n1); n1 < n2 n1 n2 return gcd(n2,n1); gcd(n2,n1) gcd n2 n1 if (n2 == 0) return n1; n2 == 0 n2 0 return n1; n1 if (n1 == n2) return n1; n1 == n2 n1 n2 return n1; n1 return gcd(n2, n1%n2); gcd(n2, n1%n2) gcd n2 n1%n2 n1 n2 int n1 n1 int n2 n2 public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		
		System.out.println(gcd(a,b));
		
	} main {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		
		System.out.println(gcd(a,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 System.out.println(gcd(a,b)) System.out.println System.out System System.out gcd(a,b) gcd a b String[] args args
import java.util.Scanner;

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

