import java.util.Scanner;

public class Main {

	static int bmp(int x,int y){
		while(y > 0){
			int r = x % y;
			x = y;
			y = r;
		}
		return x;
	}

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		String[] gcd = in.nextLine().split(" ");
		int x = Integer.parseInt(gcd[0]);
		int y = Integer.parseInt(gcd[1]);
			if(x<y){
				int big = y;
				int small = x;
				System.out.println(bmp(big,small));
			}
			else{
				int big = x;
				int small = y;
				System.out.println(bmp(big,small));
			}
		}
} import java.util.Scanner; Scanner java.util public class Main {

	static int bmp(int x,int y){
		while(y > 0){
			int r = x % y;
			x = y;
			y = r;
		}
		return x;
	}

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		String[] gcd = in.nextLine().split(" ");
		int x = Integer.parseInt(gcd[0]);
		int y = Integer.parseInt(gcd[1]);
			if(x<y){
				int big = y;
				int small = x;
				System.out.println(bmp(big,small));
			}
			else{
				int big = x;
				int small = y;
				System.out.println(bmp(big,small));
			}
		}
} Main static int bmp(int x,int y){
		while(y > 0){
			int r = x % y;
			x = y;
			y = r;
		}
		return x;
	} bmp {
		while(y > 0){
			int r = x % y;
			x = y;
			y = r;
		}
		return x;
	} while(y > 0){
			int r = x % y;
			x = y;
			y = r;
		} y > 0 y 0 {
			int r = x % y;
			x = y;
			y = r;
		} int r = x % y; r x % y x y x = y x y y = r y r return x; x int x x int y y public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		String[] gcd = in.nextLine().split(" ");
		int x = Integer.parseInt(gcd[0]);
		int y = Integer.parseInt(gcd[1]);
			if(x<y){
				int big = y;
				int small = x;
				System.out.println(bmp(big,small));
			}
			else{
				int big = x;
				int small = y;
				System.out.println(bmp(big,small));
			}
		} main {
		Scanner in = new Scanner(System.in);
		String[] gcd = in.nextLine().split(" ");
		int x = Integer.parseInt(gcd[0]);
		int y = Integer.parseInt(gcd[1]);
			if(x<y){
				int big = y;
				int small = x;
				System.out.println(bmp(big,small));
			}
			else{
				int big = x;
				int small = y;
				System.out.println(bmp(big,small));
			}
		} Scanner in = new Scanner(System.in); in new Scanner(System.in) String[] gcd = in.nextLine().split(" "); gcd in.nextLine().split(" ") in.nextLine().split in.nextLine() in.nextLine in " " int x = Integer.parseInt(gcd[0]); x Integer.parseInt(gcd[0]) Integer.parseInt Integer gcd[0] gcd 0 int y = Integer.parseInt(gcd[1]); y Integer.parseInt(gcd[1]) Integer.parseInt Integer gcd[1] gcd 1 if(x<y){
				int big = y;
				int small = x;
				System.out.println(bmp(big,small));
			}
			else{
				int big = x;
				int small = y;
				System.out.println(bmp(big,small));
			} x<y x y {
				int big = y;
				int small = x;
				System.out.println(bmp(big,small));
			} int big = y; big y int small = x; small x System.out.println(bmp(big,small)) System.out.println System.out System System.out bmp(big,small) bmp big small {
				int big = x;
				int small = y;
				System.out.println(bmp(big,small));
			} int big = x; big x int small = y; small y System.out.println(bmp(big,small)) System.out.println System.out System System.out bmp(big,small) bmp big small String[] args args public class Main {

	static int bmp(int x,int y){
		while(y > 0){
			int r = x % y;
			x = y;
			y = r;
		}
		return x;
	}

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		String[] gcd = in.nextLine().split(" ");
		int x = Integer.parseInt(gcd[0]);
		int y = Integer.parseInt(gcd[1]);
			if(x<y){
				int big = y;
				int small = x;
				System.out.println(bmp(big,small));
			}
			else{
				int big = x;
				int small = y;
				System.out.println(bmp(big,small));
			}
		}
} public class Main {

	static int bmp(int x,int y){
		while(y > 0){
			int r = x % y;
			x = y;
			y = r;
		}
		return x;
	}

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		String[] gcd = in.nextLine().split(" ");
		int x = Integer.parseInt(gcd[0]);
		int y = Integer.parseInt(gcd[1]);
			if(x<y){
				int big = y;
				int small = x;
				System.out.println(bmp(big,small));
			}
			else{
				int big = x;
				int small = y;
				System.out.println(bmp(big,small));
			}
		}
} Main
import java.util.Scanner;

public class Main {

	static int bmp(int x,int y){
		while(y > 0){
			int r = x % y;
			x = y;
			y = r;
		}
		return x;
	}

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		String[] gcd = in.nextLine().split(" ");
		int x = Integer.parseInt(gcd[0]);
		int y = Integer.parseInt(gcd[1]);
			if(x<y){
				int big = y;
				int small = x;
				System.out.println(bmp(big,small));
			}
			else{
				int big = x;
				int small = y;
				System.out.println(bmp(big,small));
			}
		}
}