
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int x = sc.nextInt();
		int y = sc.nextInt();

		System.out.println(euclideanAlgorithm(x, y));
	}

	public static int euclideanAlgorithm(int x, int y) {
		int tmp;
		while (true) {
			tmp = x % y;
			if (tmp == 0) {
				return y;
			}
			x = y;
			y = tmp;
		}
	}
}
 import java.util.Scanner; Scanner java.util public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int x = sc.nextInt();
		int y = sc.nextInt();

		System.out.println(euclideanAlgorithm(x, y));
	}

	public static int euclideanAlgorithm(int x, int y) {
		int tmp;
		while (true) {
			tmp = x % y;
			if (tmp == 0) {
				return y;
			}
			x = y;
			y = tmp;
		}
	}
} Main public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int x = sc.nextInt();
		int y = sc.nextInt();

		System.out.println(euclideanAlgorithm(x, y));
	} main {
		Scanner sc = new Scanner(System.in);

		int x = sc.nextInt();
		int y = sc.nextInt();

		System.out.println(euclideanAlgorithm(x, y));
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int x = sc.nextInt(); x sc.nextInt() sc.nextInt sc int y = sc.nextInt(); y sc.nextInt() sc.nextInt sc System.out.println(euclideanAlgorithm(x, y)) System.out.println System.out System System.out euclideanAlgorithm(x, y) euclideanAlgorithm x y String[] args args public static int euclideanAlgorithm(int x, int y) {
		int tmp;
		while (true) {
			tmp = x % y;
			if (tmp == 0) {
				return y;
			}
			x = y;
			y = tmp;
		}
	} euclideanAlgorithm {
		int tmp;
		while (true) {
			tmp = x % y;
			if (tmp == 0) {
				return y;
			}
			x = y;
			y = tmp;
		}
	} int tmp; tmp while (true) {
			tmp = x % y;
			if (tmp == 0) {
				return y;
			}
			x = y;
			y = tmp;
		} true {
			tmp = x % y;
			if (tmp == 0) {
				return y;
			}
			x = y;
			y = tmp;
		} tmp = x % y tmp x % y x y if (tmp == 0) {
				return y;
			} tmp == 0 tmp 0 {
				return y;
			} return y; y x = y x y y = tmp y tmp int x x int y y public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int x = sc.nextInt();
		int y = sc.nextInt();

		System.out.println(euclideanAlgorithm(x, y));
	}

	public static int euclideanAlgorithm(int x, int y) {
		int tmp;
		while (true) {
			tmp = x % y;
			if (tmp == 0) {
				return y;
			}
			x = y;
			y = tmp;
		}
	}
} public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int x = sc.nextInt();
		int y = sc.nextInt();

		System.out.println(euclideanAlgorithm(x, y));
	}

	public static int euclideanAlgorithm(int x, int y) {
		int tmp;
		while (true) {
			tmp = x % y;
			if (tmp == 0) {
				return y;
			}
			x = y;
			y = tmp;
		}
	}
} Main

import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int x = sc.nextInt();
		int y = sc.nextInt();

		System.out.println(euclideanAlgorithm(x, y));
	}

	public static int euclideanAlgorithm(int x, int y) {
		int tmp;
		while (true) {
			tmp = x % y;
			if (tmp == 0) {
				return y;
			}
			x = y;
			y = tmp;
		}
	}
}

