import java.util.Scanner;
class Main {
	public static void main(String[] args){
		final int Number=100;
		try(Scanner sc = new Scanner(System.in)){
			int N = Integer.parseInt(sc.next());
			int M = Integer.parseInt(sc.next());
			int c =gcd(N,M);
			System.out.println(c);
		}
	}
	public static int gcd(int N, int M){
		int max=Math.max(N, M);
		int min=Math.min(N, M);
		
		if(max%min==0){
			return min;
		}else{
			return gcd(max%min,min);
		}
	}
} import java.util.Scanner; Scanner java.util class Main {
	public static void main(String[] args){
		final int Number=100;
		try(Scanner sc = new Scanner(System.in)){
			int N = Integer.parseInt(sc.next());
			int M = Integer.parseInt(sc.next());
			int c =gcd(N,M);
			System.out.println(c);
		}
	}
	public static int gcd(int N, int M){
		int max=Math.max(N, M);
		int min=Math.min(N, M);
		
		if(max%min==0){
			return min;
		}else{
			return gcd(max%min,min);
		}
	}
} Main public static void main(String[] args){
		final int Number=100;
		try(Scanner sc = new Scanner(System.in)){
			int N = Integer.parseInt(sc.next());
			int M = Integer.parseInt(sc.next());
			int c =gcd(N,M);
			System.out.println(c);
		}
	} main {
		final int Number=100;
		try(Scanner sc = new Scanner(System.in)){
			int N = Integer.parseInt(sc.next());
			int M = Integer.parseInt(sc.next());
			int c =gcd(N,M);
			System.out.println(c);
		}
	} final int Number=100; Number 100 try(Scanner sc = new Scanner(System.in)){
			int N = Integer.parseInt(sc.next());
			int M = Integer.parseInt(sc.next());
			int c =gcd(N,M);
			System.out.println(c);
		} {
			int N = Integer.parseInt(sc.next());
			int M = Integer.parseInt(sc.next());
			int c =gcd(N,M);
			System.out.println(c);
		} Scanner sc = new Scanner(System.in) Scanner sc = new Scanner(System.in) new Scanner(System.in) int N = Integer.parseInt(sc.next()); N Integer.parseInt(sc.next()) Integer.parseInt Integer sc.next() sc.next sc int M = Integer.parseInt(sc.next()); M Integer.parseInt(sc.next()) Integer.parseInt Integer sc.next() sc.next sc int c =gcd(N,M); c gcd(N,M) gcd N M System.out.println(c) System.out.println System.out System System.out c String[] args args public static int gcd(int N, int M){
		int max=Math.max(N, M);
		int min=Math.min(N, M);
		
		if(max%min==0){
			return min;
		}else{
			return gcd(max%min,min);
		}
	} gcd {
		int max=Math.max(N, M);
		int min=Math.min(N, M);
		
		if(max%min==0){
			return min;
		}else{
			return gcd(max%min,min);
		}
	} int max=Math.max(N, M); max Math.max(N, M) Math.max Math N M int min=Math.min(N, M); min Math.min(N, M) Math.min Math N M if(max%min==0){
			return min;
		}else{
			return gcd(max%min,min);
		} max%min==0 max%min max min 0 {
			return min;
		} return min; min {
			return gcd(max%min,min);
		} return gcd(max%min,min); gcd(max%min,min) gcd max%min max min min int N N int M M
import java.util.Scanner;
class Main {
	public static void main(String[] args){
		final int Number=100;
		try(Scanner sc = new Scanner(System.in)){
			int N = Integer.parseInt(sc.next());
			int M = Integer.parseInt(sc.next());
			int c =gcd(N,M);
			System.out.println(c);
		}
	}
	public static int gcd(int N, int M){
		int max=Math.max(N, M);
		int min=Math.min(N, M);
		
		if(max%min==0){
			return min;
		}else{
			return gcd(max%min,min);
		}
	}
}