import java.util.Scanner;

public class Main{

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

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

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

	public static void main(String[] args) {
            Scanner in = new Scanner(System.in);
            int a = in.nextInt();
            int b = in.nextInt();
            in.close();
            System.out.println(Function(a, b));
            
            
            
	}
	public static int Function(int a, int b) {
		if(b != 0)
			return Function(b, a % b);
		else
			return a;
	}
} Main
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {
            Scanner in = new Scanner(System.in);
            int a = in.nextInt();
            int b = in.nextInt();
            in.close();
            System.out.println(Function(a, b));
            
            
            
	}
	public static int Function(int a, int b) {
		if(b != 0)
			return Function(b, a % b);
		else
			return a;
	}
}
	
