
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int x = scanner.nextInt();
		int y = scanner.nextInt();
		System.out.println(gcd(x, y));
	}

	public static int gcd(int x, int y) {

		int r = x % y;
		while (r != 0) {
			x = y;
			y = r;
			r = x % y;
		}
		return y;
	}
} import java.util.Scanner; Scanner java.util public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int x = scanner.nextInt();
		int y = scanner.nextInt();
		System.out.println(gcd(x, y));
	}

	public static int gcd(int x, int y) {

		int r = x % y;
		while (r != 0) {
			x = y;
			y = r;
			r = x % y;
		}
		return y;
	}
} Main public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int x = scanner.nextInt();
		int y = scanner.nextInt();
		System.out.println(gcd(x, y));
	} main {
		Scanner scanner = new Scanner(System.in);
		int x = scanner.nextInt();
		int y = scanner.nextInt();
		System.out.println(gcd(x, y));
	} Scanner scanner = new Scanner(System.in); scanner new Scanner(System.in) int x = scanner.nextInt(); x scanner.nextInt() scanner.nextInt scanner int y = scanner.nextInt(); y scanner.nextInt() scanner.nextInt scanner System.out.println(gcd(x, y)) System.out.println System.out System System.out gcd(x, y) gcd x y String[] args args public static int gcd(int x, int y) {

		int r = x % y;
		while (r != 0) {
			x = y;
			y = r;
			r = x % y;
		}
		return y;
	} gcd {

		int r = x % y;
		while (r != 0) {
			x = y;
			y = r;
			r = x % y;
		}
		return y;
	} int r = x % y; r x % y x y while (r != 0) {
			x = y;
			y = r;
			r = x % y;
		} r != 0 r 0 {
			x = y;
			y = r;
			r = x % y;
		} x = y x y y = r y r r = x % y r x % y x y return y; y int x x int y y public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int x = scanner.nextInt();
		int y = scanner.nextInt();
		System.out.println(gcd(x, y));
	}

	public static int gcd(int x, int y) {

		int r = x % y;
		while (r != 0) {
			x = y;
			y = r;
			r = x % y;
		}
		return y;
	}
} public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int x = scanner.nextInt();
		int y = scanner.nextInt();
		System.out.println(gcd(x, y));
	}

	public static int gcd(int x, int y) {

		int r = x % y;
		while (r != 0) {
			x = y;
			y = r;
			r = x % y;
		}
		return y;
	}
} Main

import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int x = scanner.nextInt();
		int y = scanner.nextInt();
		System.out.println(gcd(x, y));
	}

	public static int gcd(int x, int y) {

		int r = x % y;
		while (r != 0) {
			x = y;
			y = r;
			r = x % y;
		}
		return y;
	}
}