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

public class Main {

	public static void main(String[] args) throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] arrays = br.readLine().split(" ");
		
		int x = Integer.parseInt(arrays[0]);
		int y = Integer.parseInt(arrays[1]);
		
		if(x > y){
			System.out.println(gcd(x, y));
		}
		else {
			System.out.println(gcd(y, x));
		}

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

		if (y == 0) {
			return x;
		} else {
			return gcd(y, x % y);

		}

	}
} import java.io.BufferedReader; BufferedReader java.io import java.io.IOException; IOException java.io import java.io.InputStreamReader; InputStreamReader java.io public class Main {

	public static void main(String[] args) throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] arrays = br.readLine().split(" ");
		
		int x = Integer.parseInt(arrays[0]);
		int y = Integer.parseInt(arrays[1]);
		
		if(x > y){
			System.out.println(gcd(x, y));
		}
		else {
			System.out.println(gcd(y, x));
		}

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

		if (y == 0) {
			return x;
		} else {
			return gcd(y, x % y);

		}

	}
} Main public static void main(String[] args) throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] arrays = br.readLine().split(" ");
		
		int x = Integer.parseInt(arrays[0]);
		int y = Integer.parseInt(arrays[1]);
		
		if(x > y){
			System.out.println(gcd(x, y));
		}
		else {
			System.out.println(gcd(y, x));
		}

	} main {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] arrays = br.readLine().split(" ");
		
		int x = Integer.parseInt(arrays[0]);
		int y = Integer.parseInt(arrays[1]);
		
		if(x > y){
			System.out.println(gcd(x, y));
		}
		else {
			System.out.println(gcd(y, x));
		}

	} BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) String[] arrays = br.readLine().split(" "); arrays br.readLine().split(" ") br.readLine().split br.readLine() br.readLine br " " int x = Integer.parseInt(arrays[0]); x Integer.parseInt(arrays[0]) Integer.parseInt Integer arrays[0] arrays 0 int y = Integer.parseInt(arrays[1]); y Integer.parseInt(arrays[1]) Integer.parseInt Integer arrays[1] arrays 1 if(x > y){
			System.out.println(gcd(x, y));
		}
		else {
			System.out.println(gcd(y, x));
		} x > y x y {
			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 {
			System.out.println(gcd(y, x));
		} System.out.println(gcd(y, x)) System.out.println System.out System System.out gcd(y, x) gcd y x String[] args args static int gcd(int x, int y) {

		if (y == 0) {
			return x;
		} else {
			return gcd(y, x % y);

		}

	} gcd {

		if (y == 0) {
			return x;
		} else {
			return gcd(y, x % y);

		}

	} if (y == 0) {
			return x;
		} else {
			return gcd(y, x % y);

		} y == 0 y 0 {
			return x;
		} return x; x {
			return gcd(y, x % y);

		} return gcd(y, x % y); 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 IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] arrays = br.readLine().split(" ");
		
		int x = Integer.parseInt(arrays[0]);
		int y = Integer.parseInt(arrays[1]);
		
		if(x > y){
			System.out.println(gcd(x, y));
		}
		else {
			System.out.println(gcd(y, x));
		}

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

		if (y == 0) {
			return x;
		} else {
			return gcd(y, x % y);

		}

	}
} public class Main {

	public static void main(String[] args) throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] arrays = br.readLine().split(" ");
		
		int x = Integer.parseInt(arrays[0]);
		int y = Integer.parseInt(arrays[1]);
		
		if(x > y){
			System.out.println(gcd(x, y));
		}
		else {
			System.out.println(gcd(y, x));
		}

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

		if (y == 0) {
			return x;
		} else {
			return gcd(y, x % y);

		}

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

public class Main {

	public static void main(String[] args) throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] arrays = br.readLine().split(" ");
		
		int x = Integer.parseInt(arrays[0]);
		int y = Integer.parseInt(arrays[1]);
		
		if(x > y){
			System.out.println(gcd(x, y));
		}
		else {
			System.out.println(gcd(y, x));
		}

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

		if (y == 0) {
			return x;
		} else {
			return gcd(y, x % y);

		}

	}
}