import java.util.*;

public class Main{
	private static final Scanner scan = new Scanner(System.in);

	public static void main(String[] args){
		int x = scan.nextInt();
		int y = scan.nextInt();

		System.out.printf("%d\n", gcd(x, y));
	}

	public static int gcd(int x, int y){
		if(x < y){
			int work = y;
			y = x;
			x = work;
		}
		while(y > 0){
			int r = x % y;
			x = y;
			y = r;
		}
		return x;
	}
} import java.util.*; util.* java public class Main{
	private static final Scanner scan = new Scanner(System.in);

	public static void main(String[] args){
		int x = scan.nextInt();
		int y = scan.nextInt();

		System.out.printf("%d\n", gcd(x, y));
	}

	public static int gcd(int x, int y){
		if(x < y){
			int work = y;
			y = x;
			x = work;
		}
		while(y > 0){
			int r = x % y;
			x = y;
			y = r;
		}
		return x;
	}
} Main private static final Scanner scan = new Scanner(System.in); scan new Scanner(System.in) public static void main(String[] args){
		int x = scan.nextInt();
		int y = scan.nextInt();

		System.out.printf("%d\n", gcd(x, y));
	} main {
		int x = scan.nextInt();
		int y = scan.nextInt();

		System.out.printf("%d\n", gcd(x, y));
	} int x = scan.nextInt(); x scan.nextInt() scan.nextInt scan int y = scan.nextInt(); y scan.nextInt() scan.nextInt scan System.out.printf("%d\n", gcd(x, y)) System.out.printf System.out System System.out "%d\n" gcd(x, y) gcd x y String[] args args public static int gcd(int x, int y){
		if(x < y){
			int work = y;
			y = x;
			x = work;
		}
		while(y > 0){
			int r = x % y;
			x = y;
			y = r;
		}
		return x;
	} gcd {
		if(x < y){
			int work = y;
			y = x;
			x = work;
		}
		while(y > 0){
			int r = x % y;
			x = y;
			y = r;
		}
		return x;
	} if(x < y){
			int work = y;
			y = x;
			x = work;
		} x < y x y {
			int work = y;
			y = x;
			x = work;
		} int work = y; work y y = x y x x = work x work 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 class Main{
	private static final Scanner scan = new Scanner(System.in);

	public static void main(String[] args){
		int x = scan.nextInt();
		int y = scan.nextInt();

		System.out.printf("%d\n", gcd(x, y));
	}

	public static int gcd(int x, int y){
		if(x < y){
			int work = y;
			y = x;
			x = work;
		}
		while(y > 0){
			int r = x % y;
			x = y;
			y = r;
		}
		return x;
	}
} public class Main{
	private static final Scanner scan = new Scanner(System.in);

	public static void main(String[] args){
		int x = scan.nextInt();
		int y = scan.nextInt();

		System.out.printf("%d\n", gcd(x, y));
	}

	public static int gcd(int x, int y){
		if(x < y){
			int work = y;
			y = x;
			x = work;
		}
		while(y > 0){
			int r = x % y;
			x = y;
			y = r;
		}
		return x;
	}
} Main
import java.util.*;

public class Main{
	private static final Scanner scan = new Scanner(System.in);

	public static void main(String[] args){
		int x = scan.nextInt();
		int y = scan.nextInt();

		System.out.printf("%d\n", gcd(x, y));
	}

	public static int gcd(int x, int y){
		if(x < y){
			int work = y;
			y = x;
			x = work;
		}
		while(y > 0){
			int r = x % y;
			x = y;
			y = r;
		}
		return x;
	}
}