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

class Main{

	public static void main(String[] args) throws IOException {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] input = br.readLine().split(" ");
		int x = Integer.parseInt(input[0]);
		int y = Integer.parseInt(input[1]);

		System.out.println(gcd(x, y));

	}

	public static int gcd(int a, int b){

		if(b == 0){
			return a;
		}else{
			return gcd(b, a % b);
		}

	}

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

	public static void main(String[] args) throws IOException {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] input = br.readLine().split(" ");
		int x = Integer.parseInt(input[0]);
		int y = Integer.parseInt(input[1]);

		System.out.println(gcd(x, y));

	}

	public static int gcd(int a, int b){

		if(b == 0){
			return a;
		}else{
			return gcd(b, a % b);
		}

	}

} Main public static void main(String[] args) throws IOException {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] input = br.readLine().split(" ");
		int x = Integer.parseInt(input[0]);
		int y = Integer.parseInt(input[1]);

		System.out.println(gcd(x, y));

	} main {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] input = br.readLine().split(" ");
		int x = Integer.parseInt(input[0]);
		int y = Integer.parseInt(input[1]);

		System.out.println(gcd(x, y));

	} BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) String[] input = br.readLine().split(" "); input br.readLine().split(" ") br.readLine().split br.readLine() br.readLine br " " int x = Integer.parseInt(input[0]); x Integer.parseInt(input[0]) Integer.parseInt Integer input[0] input 0 int y = Integer.parseInt(input[1]); y Integer.parseInt(input[1]) Integer.parseInt Integer input[1] input 1 System.out.println(gcd(x, y)) System.out.println System.out System System.out gcd(x, y) gcd x y String[] args args public static int gcd(int a, int b){

		if(b == 0){
			return a;
		}else{
			return gcd(b, a % b);
		}

	} gcd {

		if(b == 0){
			return a;
		}else{
			return gcd(b, a % b);
		}

	} if(b == 0){
			return a;
		}else{
			return gcd(b, a % b);
		} b == 0 b 0 {
			return a;
		} return a; a {
			return gcd(b, a % b);
		} return gcd(b, a % b); gcd(b, a % b) gcd b a % b a b int a a int b b
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;

class Main{

	public static void main(String[] args) throws IOException {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] input = br.readLine().split(" ");
		int x = Integer.parseInt(input[0]);
		int y = Integer.parseInt(input[1]);

		System.out.println(gcd(x, y));

	}

	public static int gcd(int a, int b){

		if(b == 0){
			return a;
		}else{
			return gcd(b, a % b);
		}

	}

}