import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scn = new Scanner(System.in);
		int x = scn.nextInt();
		int y = scn.nextInt();

		if (x >= y) {
			System.out.println(calculate(x, y));
		} else if (x < y) {
			System.out.println(calculate(y, x));
		}
	}

	private static int calculate(int a, int b) {
		int tempt;
		while ((tempt = a % b) != 0) {
			a = b;
			b = tempt;
		}
		return b;
	}
}
 import java.util.Scanner; Scanner java.util public class Main {
	public static void main(String[] args) {
		Scanner scn = new Scanner(System.in);
		int x = scn.nextInt();
		int y = scn.nextInt();

		if (x >= y) {
			System.out.println(calculate(x, y));
		} else if (x < y) {
			System.out.println(calculate(y, x));
		}
	}

	private static int calculate(int a, int b) {
		int tempt;
		while ((tempt = a % b) != 0) {
			a = b;
			b = tempt;
		}
		return b;
	}
} Main public static void main(String[] args) {
		Scanner scn = new Scanner(System.in);
		int x = scn.nextInt();
		int y = scn.nextInt();

		if (x >= y) {
			System.out.println(calculate(x, y));
		} else if (x < y) {
			System.out.println(calculate(y, x));
		}
	} main {
		Scanner scn = new Scanner(System.in);
		int x = scn.nextInt();
		int y = scn.nextInt();

		if (x >= y) {
			System.out.println(calculate(x, y));
		} else if (x < y) {
			System.out.println(calculate(y, x));
		}
	} Scanner scn = new Scanner(System.in); scn new Scanner(System.in) int x = scn.nextInt(); x scn.nextInt() scn.nextInt scn int y = scn.nextInt(); y scn.nextInt() scn.nextInt scn if (x >= y) {
			System.out.println(calculate(x, y));
		} else if (x < y) {
			System.out.println(calculate(y, x));
		} x >= y x y {
			System.out.println(calculate(x, y));
		} System.out.println(calculate(x, y)) System.out.println System.out System System.out calculate(x, y) calculate x y if (x < y) {
			System.out.println(calculate(y, x));
		} x < y x y {
			System.out.println(calculate(y, x));
		} System.out.println(calculate(y, x)) System.out.println System.out System System.out calculate(y, x) calculate y x String[] args args private static int calculate(int a, int b) {
		int tempt;
		while ((tempt = a % b) != 0) {
			a = b;
			b = tempt;
		}
		return b;
	} calculate {
		int tempt;
		while ((tempt = a % b) != 0) {
			a = b;
			b = tempt;
		}
		return b;
	} int tempt; tempt while ((tempt = a % b) != 0) {
			a = b;
			b = tempt;
		} (tempt = a % b) != 0 (tempt = a % b) tempt a % b a b 0 {
			a = b;
			b = tempt;
		} a = b a b b = tempt b tempt return b; b int a a int b b public class Main {
	public static void main(String[] args) {
		Scanner scn = new Scanner(System.in);
		int x = scn.nextInt();
		int y = scn.nextInt();

		if (x >= y) {
			System.out.println(calculate(x, y));
		} else if (x < y) {
			System.out.println(calculate(y, x));
		}
	}

	private static int calculate(int a, int b) {
		int tempt;
		while ((tempt = a % b) != 0) {
			a = b;
			b = tempt;
		}
		return b;
	}
} public class Main {
	public static void main(String[] args) {
		Scanner scn = new Scanner(System.in);
		int x = scn.nextInt();
		int y = scn.nextInt();

		if (x >= y) {
			System.out.println(calculate(x, y));
		} else if (x < y) {
			System.out.println(calculate(y, x));
		}
	}

	private static int calculate(int a, int b) {
		int tempt;
		while ((tempt = a % b) != 0) {
			a = b;
			b = tempt;
		}
		return b;
	}
} Main
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scn = new Scanner(System.in);
		int x = scn.nextInt();
		int y = scn.nextInt();

		if (x >= y) {
			System.out.println(calculate(x, y));
		} else if (x < y) {
			System.out.println(calculate(y, x));
		}
	}

	private static int calculate(int a, int b) {
		int tempt;
		while ((tempt = a % b) != 0) {
			a = b;
			b = tempt;
		}
		return b;
	}
}

