import java.io.BufferedReader;
import java.io.InputStreamReader;
 
public class Main
{
	public static void main (String[] args) throws Exception
	{
		BufferedReader stdReader =
		new BufferedReader(new InputStreamReader(System.in));
		String natural[] = stdReader.readLine().split(" ",0);
		int x = Integer.parseInt(natural[0]);
		int y = Integer.parseInt(natural[1]);
		if (x < y) {
			x = x^y;
			y = x^y;
			x = x^y;
		}
		System.out.println(gcd(x, y));
	}
	private static int gcd(int x, int y) {
		return y == 0? x: gcd(y, x % y);
	}
} import java.io.BufferedReader; BufferedReader java.io import java.io.InputStreamReader; InputStreamReader java.io public class Main
{
	public static void main (String[] args) throws Exception
	{
		BufferedReader stdReader =
		new BufferedReader(new InputStreamReader(System.in));
		String natural[] = stdReader.readLine().split(" ",0);
		int x = Integer.parseInt(natural[0]);
		int y = Integer.parseInt(natural[1]);
		if (x < y) {
			x = x^y;
			y = x^y;
			x = x^y;
		}
		System.out.println(gcd(x, y));
	}
	private static int gcd(int x, int y) {
		return y == 0? x: gcd(y, x % y);
	}
} Main public static void main (String[] args) throws Exception
	{
		BufferedReader stdReader =
		new BufferedReader(new InputStreamReader(System.in));
		String natural[] = stdReader.readLine().split(" ",0);
		int x = Integer.parseInt(natural[0]);
		int y = Integer.parseInt(natural[1]);
		if (x < y) {
			x = x^y;
			y = x^y;
			x = x^y;
		}
		System.out.println(gcd(x, y));
	} main {
		BufferedReader stdReader =
		new BufferedReader(new InputStreamReader(System.in));
		String natural[] = stdReader.readLine().split(" ",0);
		int x = Integer.parseInt(natural[0]);
		int y = Integer.parseInt(natural[1]);
		if (x < y) {
			x = x^y;
			y = x^y;
			x = x^y;
		}
		System.out.println(gcd(x, y));
	} BufferedReader stdReader =
		new BufferedReader(new InputStreamReader(System.in)); stdReader new BufferedReader(new InputStreamReader(System.in)) String natural[] = stdReader.readLine().split(" ",0); natural stdReader.readLine().split(" ",0) stdReader.readLine().split stdReader.readLine() stdReader.readLine stdReader " " 0 int x = Integer.parseInt(natural[0]); x Integer.parseInt(natural[0]) Integer.parseInt Integer natural[0] natural 0 int y = Integer.parseInt(natural[1]); y Integer.parseInt(natural[1]) Integer.parseInt Integer natural[1] natural 1 if (x < y) {
			x = x^y;
			y = x^y;
			x = x^y;
		} x < y x y {
			x = x^y;
			y = x^y;
			x = x^y;
		} x = x^y x x^y x y y = x^y y x^y x y x = x^y x x^y x y System.out.println(gcd(x, y)) System.out.println System.out System System.out gcd(x, y) gcd x y String[] args args private static int gcd(int x, int y) {
		return y == 0? x: gcd(y, x % y);
	} gcd {
		return y == 0? x: gcd(y, x % y);
	} return y == 0? x: gcd(y, x % y); y == 0? x: gcd(y, x % y) y == 0 y 0 x gcd(y, x % y) gcd y x % y x y int x x int y y public class Main
{
	public static void main (String[] args) throws Exception
	{
		BufferedReader stdReader =
		new BufferedReader(new InputStreamReader(System.in));
		String natural[] = stdReader.readLine().split(" ",0);
		int x = Integer.parseInt(natural[0]);
		int y = Integer.parseInt(natural[1]);
		if (x < y) {
			x = x^y;
			y = x^y;
			x = x^y;
		}
		System.out.println(gcd(x, y));
	}
	private static int gcd(int x, int y) {
		return y == 0? x: gcd(y, x % y);
	}
} public class Main
{
	public static void main (String[] args) throws Exception
	{
		BufferedReader stdReader =
		new BufferedReader(new InputStreamReader(System.in));
		String natural[] = stdReader.readLine().split(" ",0);
		int x = Integer.parseInt(natural[0]);
		int y = Integer.parseInt(natural[1]);
		if (x < y) {
			x = x^y;
			y = x^y;
			x = x^y;
		}
		System.out.println(gcd(x, y));
	}
	private static int gcd(int x, int y) {
		return y == 0? x: gcd(y, x % y);
	}
} Main
import java.io.BufferedReader;
import java.io.InputStreamReader;
 
public class Main
{
	public static void main (String[] args) throws Exception
	{
		BufferedReader stdReader =
		new BufferedReader(new InputStreamReader(System.in));
		String natural[] = stdReader.readLine().split(" ",0);
		int x = Integer.parseInt(natural[0]);
		int y = Integer.parseInt(natural[1]);
		if (x < y) {
			x = x^y;
			y = x^y;
			x = x^y;
		}
		System.out.println(gcd(x, y));
	}
	private static int gcd(int x, int y) {
		return y == 0? x: gcd(y, x % y);
	}
}