import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {
	
	public static long gcd(long a, long b){
		if(b == 0){ return a; }
		else {return gcd(b, a % b);}
	}
	
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		
		final long a = sc.nextLong();
		final long b = sc.nextLong();
		
		System.out.println(gcd(a, b));
		
	}
} import java.util.Arrays; Arrays java.util import java.util.HashMap; HashMap java.util import java.util.Map; Map java.util import java.util.Scanner; Scanner java.util public class Main {
	
	public static long gcd(long a, long b){
		if(b == 0){ return a; }
		else {return gcd(b, a % b);}
	}
	
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		
		final long a = sc.nextLong();
		final long b = sc.nextLong();
		
		System.out.println(gcd(a, b));
		
	}
} Main public static long gcd(long a, long b){
		if(b == 0){ return a; }
		else {return gcd(b, a % b);}
	} gcd {
		if(b == 0){ return a; }
		else {return gcd(b, a % b);}
	} if(b == 0){ return a; }
		else {return gcd(b, a % b);} b == 0 b 0 { return a; } return a; a {return gcd(b, a % b);} return gcd(b, a % b); gcd(b, a % b) gcd b a % b a b long a a long b b public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		
		final long a = sc.nextLong();
		final long b = sc.nextLong();
		
		System.out.println(gcd(a, b));
		
	} main {
		Scanner sc = new Scanner(System.in);
		
		final long a = sc.nextLong();
		final long b = sc.nextLong();
		
		System.out.println(gcd(a, b));
		
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) final long a = sc.nextLong(); a sc.nextLong() sc.nextLong sc final long b = sc.nextLong(); b sc.nextLong() sc.nextLong sc System.out.println(gcd(a, b)) System.out.println System.out System System.out gcd(a, b) gcd a b String args[] args public class Main {
	
	public static long gcd(long a, long b){
		if(b == 0){ return a; }
		else {return gcd(b, a % b);}
	}
	
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		
		final long a = sc.nextLong();
		final long b = sc.nextLong();
		
		System.out.println(gcd(a, b));
		
	}
} public class Main {
	
	public static long gcd(long a, long b){
		if(b == 0){ return a; }
		else {return gcd(b, a % b);}
	}
	
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		
		final long a = sc.nextLong();
		final long b = sc.nextLong();
		
		System.out.println(gcd(a, b));
		
	}
} Main
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {
	
	public static long gcd(long a, long b){
		if(b == 0){ return a; }
		else {return gcd(b, a % b);}
	}
	
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		
		final long a = sc.nextLong();
		final long b = sc.nextLong();
		
		System.out.println(gcd(a, b));
		
	}
}