import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	
	static int x, y;
	
	static void input() throws IOException {
		int[] num = readMultiInt();
		x = num[0];
		y = num[1];
	}
	
	static void process() {
	}
	
	static int gcd(int num1, int num2) {
		if(num2 == 0) {
			return num1;
		} else {
			return gcd(num2, num1 % num2);
		}
	}
	
	static void output() {
		System.out.println(gcd(x, y));
	}
	
	//??\?????±?????¨???
	static BufferedReader in;
	
	static void initBufferedReader() {
		in = new BufferedReader(new InputStreamReader(System.in));
	}
	
	static String readString() throws IOException {
		return in.readLine();
	}
	
	static int readInt() throws NumberFormatException, IOException {
		return Integer.valueOf(readString());
	}
	
	static int[] readMultiInt() throws IOException {
		String input = readString();
		String[] values = input.split(" ");
		int[] result = new int[values.length];
		for (int i = 0; i < values.length; i++) {
			result[i] = Integer.valueOf(values[i]);
		}
		return result;
	}
	
	static String arrayToString(int[] data) {
		String result = "";
		for (int i = 0; i < data.length; i++) {
			if (i >= data.length - 1) {
				result += String.valueOf(data[i]);
			} else {
				result += String.valueOf(data[i]) + " ";
			}
		}
		return result;
	}
	
	static long factional(int n) {
		int result = 1;
		for (int i = 1; i <= n; i++) {
			result *= i;
		}
		return result;
	}
	
	public static void main(String[] args) throws IOException {
		initBufferedReader();
		input();
		process();
		output();
	}
	
} import java.io.BufferedReader; BufferedReader java.io import java.io.IOException; IOException java.io import java.io.InputStreamReader; InputStreamReader java.io public class Main {
	
	static int x, y;
	
	static void input() throws IOException {
		int[] num = readMultiInt();
		x = num[0];
		y = num[1];
	}
	
	static void process() {
	}
	
	static int gcd(int num1, int num2) {
		if(num2 == 0) {
			return num1;
		} else {
			return gcd(num2, num1 % num2);
		}
	}
	
	static void output() {
		System.out.println(gcd(x, y));
	}
	
	//??\?????±?????¨???
	static BufferedReader in;
	
	static void initBufferedReader() {
		in = new BufferedReader(new InputStreamReader(System.in));
	}
	
	static String readString() throws IOException {
		return in.readLine();
	}
	
	static int readInt() throws NumberFormatException, IOException {
		return Integer.valueOf(readString());
	}
	
	static int[] readMultiInt() throws IOException {
		String input = readString();
		String[] values = input.split(" ");
		int[] result = new int[values.length];
		for (int i = 0; i < values.length; i++) {
			result[i] = Integer.valueOf(values[i]);
		}
		return result;
	}
	
	static String arrayToString(int[] data) {
		String result = "";
		for (int i = 0; i < data.length; i++) {
			if (i >= data.length - 1) {
				result += String.valueOf(data[i]);
			} else {
				result += String.valueOf(data[i]) + " ";
			}
		}
		return result;
	}
	
	static long factional(int n) {
		int result = 1;
		for (int i = 1; i <= n; i++) {
			result *= i;
		}
		return result;
	}
	
	public static void main(String[] args) throws IOException {
		initBufferedReader();
		input();
		process();
		output();
	}
	
} Main static int x x y; y //??\?????±?????¨???
	static BufferedReader in; in static void input() throws IOException {
		int[] num = readMultiInt();
		x = num[0];
		y = num[1];
	} input {
		int[] num = readMultiInt();
		x = num[0];
		y = num[1];
	} int[] num = readMultiInt(); num readMultiInt() readMultiInt x = num[0] x num[0] num 0 y = num[1] y num[1] num 1 static void process() {
	} process {
	} static int gcd(int num1, int num2) {
		if(num2 == 0) {
			return num1;
		} else {
			return gcd(num2, num1 % num2);
		}
	} gcd {
		if(num2 == 0) {
			return num1;
		} else {
			return gcd(num2, num1 % num2);
		}
	} if(num2 == 0) {
			return num1;
		} else {
			return gcd(num2, num1 % num2);
		} num2 == 0 num2 0 {
			return num1;
		} return num1; num1 {
			return gcd(num2, num1 % num2);
		} return gcd(num2, num1 % num2); gcd(num2, num1 % num2) gcd num2 num1 % num2 num1 num2 int num1 num1 int num2 num2 static void output() {
		System.out.println(gcd(x, y));
	} output {
		System.out.println(gcd(x, y));
	} System.out.println(gcd(x, y)) System.out.println System.out System System.out gcd(x, y) gcd x y static void initBufferedReader() {
		in = new BufferedReader(new InputStreamReader(System.in));
	} initBufferedReader {
		in = new BufferedReader(new InputStreamReader(System.in));
	} in = new BufferedReader(new InputStreamReader(System.in)) in new BufferedReader(new InputStreamReader(System.in)) static String readString() throws IOException {
		return in.readLine();
	} readString {
		return in.readLine();
	} return in.readLine(); in.readLine() in.readLine in static int readInt() throws NumberFormatException, IOException {
		return Integer.valueOf(readString());
	} readInt {
		return Integer.valueOf(readString());
	} return Integer.valueOf(readString()); Integer.valueOf(readString()) Integer.valueOf Integer readString() readString static int[] readMultiInt() throws IOException {
		String input = readString();
		String[] values = input.split(" ");
		int[] result = new int[values.length];
		for (int i = 0; i < values.length; i++) {
			result[i] = Integer.valueOf(values[i]);
		}
		return result;
	} readMultiInt {
		String input = readString();
		String[] values = input.split(" ");
		int[] result = new int[values.length];
		for (int i = 0; i < values.length; i++) {
			result[i] = Integer.valueOf(values[i]);
		}
		return result;
	} String input = readString(); input readString() readString String[] values = input.split(" "); values input.split(" ") input.split input " " int[] result = new int[values.length]; result new int[values.length] values.length values values.length for (int i = 0; i < values.length; i++) {
			result[i] = Integer.valueOf(values[i]);
		} int i = 0; int i = 0; i 0 i < values.length i values.length values values.length i++ i++ i {
			result[i] = Integer.valueOf(values[i]);
		} {
			result[i] = Integer.valueOf(values[i]);
		} result[i] = Integer.valueOf(values[i]) result[i] result i Integer.valueOf(values[i]) Integer.valueOf Integer values[i] values i return result; result static String arrayToString(int[] data) {
		String result = "";
		for (int i = 0; i < data.length; i++) {
			if (i >= data.length - 1) {
				result += String.valueOf(data[i]);
			} else {
				result += String.valueOf(data[i]) + " ";
			}
		}
		return result;
	} arrayToString {
		String result = "";
		for (int i = 0; i < data.length; i++) {
			if (i >= data.length - 1) {
				result += String.valueOf(data[i]);
			} else {
				result += String.valueOf(data[i]) + " ";
			}
		}
		return result;
	} String result = ""; result "" for (int i = 0; i < data.length; i++) {
			if (i >= data.length - 1) {
				result += String.valueOf(data[i]);
			} else {
				result += String.valueOf(data[i]) + " ";
			}
		} int i = 0; int i = 0; i 0 i < data.length i data.length data data.length i++ i++ i {
			if (i >= data.length - 1) {
				result += String.valueOf(data[i]);
			} else {
				result += String.valueOf(data[i]) + " ";
			}
		} {
			if (i >= data.length - 1) {
				result += String.valueOf(data[i]);
			} else {
				result += String.valueOf(data[i]) + " ";
			}
		} if (i >= data.length - 1) {
				result += String.valueOf(data[i]);
			} else {
				result += String.valueOf(data[i]) + " ";
			} i >= data.length - 1 i data.length - 1 data.length data data.length 1 {
				result += String.valueOf(data[i]);
			} result += String.valueOf(data[i]) result String.valueOf(data[i]) String.valueOf String data[i] data i {
				result += String.valueOf(data[i]) + " ";
			} result += String.valueOf(data[i]) + " " result String.valueOf(data[i]) + " " String.valueOf(data[i]) String.valueOf String data[i] data i " " return result; result int[] data data static long factional(int n) {
		int result = 1;
		for (int i = 1; i <= n; i++) {
			result *= i;
		}
		return result;
	} factional {
		int result = 1;
		for (int i = 1; i <= n; i++) {
			result *= i;
		}
		return result;
	} int result = 1; result 1 for (int i = 1; i <= n; i++) {
			result *= i;
		} int i = 1; int i = 1; i 1 i <= n i n i++ i++ i {
			result *= i;
		} {
			result *= i;
		} result *= i result i return result; result int n n public static void main(String[] args) throws IOException {
		initBufferedReader();
		input();
		process();
		output();
	} main {
		initBufferedReader();
		input();
		process();
		output();
	} initBufferedReader() initBufferedReader input() input process() process output() output String[] args args public class Main {
	
	static int x, y;
	
	static void input() throws IOException {
		int[] num = readMultiInt();
		x = num[0];
		y = num[1];
	}
	
	static void process() {
	}
	
	static int gcd(int num1, int num2) {
		if(num2 == 0) {
			return num1;
		} else {
			return gcd(num2, num1 % num2);
		}
	}
	
	static void output() {
		System.out.println(gcd(x, y));
	}
	
	//??\?????±?????¨???
	static BufferedReader in;
	
	static void initBufferedReader() {
		in = new BufferedReader(new InputStreamReader(System.in));
	}
	
	static String readString() throws IOException {
		return in.readLine();
	}
	
	static int readInt() throws NumberFormatException, IOException {
		return Integer.valueOf(readString());
	}
	
	static int[] readMultiInt() throws IOException {
		String input = readString();
		String[] values = input.split(" ");
		int[] result = new int[values.length];
		for (int i = 0; i < values.length; i++) {
			result[i] = Integer.valueOf(values[i]);
		}
		return result;
	}
	
	static String arrayToString(int[] data) {
		String result = "";
		for (int i = 0; i < data.length; i++) {
			if (i >= data.length - 1) {
				result += String.valueOf(data[i]);
			} else {
				result += String.valueOf(data[i]) + " ";
			}
		}
		return result;
	}
	
	static long factional(int n) {
		int result = 1;
		for (int i = 1; i <= n; i++) {
			result *= i;
		}
		return result;
	}
	
	public static void main(String[] args) throws IOException {
		initBufferedReader();
		input();
		process();
		output();
	}
	
} public class Main {
	
	static int x, y;
	
	static void input() throws IOException {
		int[] num = readMultiInt();
		x = num[0];
		y = num[1];
	}
	
	static void process() {
	}
	
	static int gcd(int num1, int num2) {
		if(num2 == 0) {
			return num1;
		} else {
			return gcd(num2, num1 % num2);
		}
	}
	
	static void output() {
		System.out.println(gcd(x, y));
	}
	
	//??\?????±?????¨???
	static BufferedReader in;
	
	static void initBufferedReader() {
		in = new BufferedReader(new InputStreamReader(System.in));
	}
	
	static String readString() throws IOException {
		return in.readLine();
	}
	
	static int readInt() throws NumberFormatException, IOException {
		return Integer.valueOf(readString());
	}
	
	static int[] readMultiInt() throws IOException {
		String input = readString();
		String[] values = input.split(" ");
		int[] result = new int[values.length];
		for (int i = 0; i < values.length; i++) {
			result[i] = Integer.valueOf(values[i]);
		}
		return result;
	}
	
	static String arrayToString(int[] data) {
		String result = "";
		for (int i = 0; i < data.length; i++) {
			if (i >= data.length - 1) {
				result += String.valueOf(data[i]);
			} else {
				result += String.valueOf(data[i]) + " ";
			}
		}
		return result;
	}
	
	static long factional(int n) {
		int result = 1;
		for (int i = 1; i <= n; i++) {
			result *= i;
		}
		return result;
	}
	
	public static void main(String[] args) throws IOException {
		initBufferedReader();
		input();
		process();
		output();
	}
	
} Main
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	
	static int x, y;
	
	static void input() throws IOException {
		int[] num = readMultiInt();
		x = num[0];
		y = num[1];
	}
	
	static void process() {
	}
	
	static int gcd(int num1, int num2) {
		if(num2 == 0) {
			return num1;
		} else {
			return gcd(num2, num1 % num2);
		}
	}
	
	static void output() {
		System.out.println(gcd(x, y));
	}
	
	//??\?????±?????¨???
	static BufferedReader in;
	
	static void initBufferedReader() {
		in = new BufferedReader(new InputStreamReader(System.in));
	}
	
	static String readString() throws IOException {
		return in.readLine();
	}
	
	static int readInt() throws NumberFormatException, IOException {
		return Integer.valueOf(readString());
	}
	
	static int[] readMultiInt() throws IOException {
		String input = readString();
		String[] values = input.split(" ");
		int[] result = new int[values.length];
		for (int i = 0; i < values.length; i++) {
			result[i] = Integer.valueOf(values[i]);
		}
		return result;
	}
	
	static String arrayToString(int[] data) {
		String result = "";
		for (int i = 0; i < data.length; i++) {
			if (i >= data.length - 1) {
				result += String.valueOf(data[i]);
			} else {
				result += String.valueOf(data[i]) + " ";
			}
		}
		return result;
	}
	
	static long factional(int n) {
		int result = 1;
		for (int i = 1; i <= n; i++) {
			result *= i;
		}
		return result;
	}
	
	public static void main(String[] args) throws IOException {
		initBufferedReader();
		input();
		process();
		output();
	}
	
}