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[] strArray = br.readLine().split(" ");
		int a = Integer.parseInt(strArray[0]);
		int b = Integer.parseInt(strArray[1]);
		if (a >= b) {
			System.out.println(getGCD(a, b));
		} else {
			System.out.println(getGCD(b, a));
		}
	}

	public static int getGCD(int a, int b) {
		if (a % b == 0) return b;
		else if (a < b) {
			return getGCD(b % a, a);
		}
		else return getGCD(b, a % b);
	}
} 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[] strArray = br.readLine().split(" ");
		int a = Integer.parseInt(strArray[0]);
		int b = Integer.parseInt(strArray[1]);
		if (a >= b) {
			System.out.println(getGCD(a, b));
		} else {
			System.out.println(getGCD(b, a));
		}
	}

	public static int getGCD(int a, int b) {
		if (a % b == 0) return b;
		else if (a < b) {
			return getGCD(b % a, a);
		}
		else return getGCD(b, a % b);
	}
} Main public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] strArray = br.readLine().split(" ");
		int a = Integer.parseInt(strArray[0]);
		int b = Integer.parseInt(strArray[1]);
		if (a >= b) {
			System.out.println(getGCD(a, b));
		} else {
			System.out.println(getGCD(b, a));
		}
	} main {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] strArray = br.readLine().split(" ");
		int a = Integer.parseInt(strArray[0]);
		int b = Integer.parseInt(strArray[1]);
		if (a >= b) {
			System.out.println(getGCD(a, b));
		} else {
			System.out.println(getGCD(b, a));
		}
	} BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) String[] strArray = br.readLine().split(" "); strArray br.readLine().split(" ") br.readLine().split br.readLine() br.readLine br " " int a = Integer.parseInt(strArray[0]); a Integer.parseInt(strArray[0]) Integer.parseInt Integer strArray[0] strArray 0 int b = Integer.parseInt(strArray[1]); b Integer.parseInt(strArray[1]) Integer.parseInt Integer strArray[1] strArray 1 if (a >= b) {
			System.out.println(getGCD(a, b));
		} else {
			System.out.println(getGCD(b, a));
		} a >= b a b {
			System.out.println(getGCD(a, b));
		} System.out.println(getGCD(a, b)) System.out.println System.out System System.out getGCD(a, b) getGCD a b {
			System.out.println(getGCD(b, a));
		} System.out.println(getGCD(b, a)) System.out.println System.out System System.out getGCD(b, a) getGCD b a String[] args args public static int getGCD(int a, int b) {
		if (a % b == 0) return b;
		else if (a < b) {
			return getGCD(b % a, a);
		}
		else return getGCD(b, a % b);
	} getGCD {
		if (a % b == 0) return b;
		else if (a < b) {
			return getGCD(b % a, a);
		}
		else return getGCD(b, a % b);
	} if (a % b == 0) return b;
		else if (a < b) {
			return getGCD(b % a, a);
		}
		else return getGCD(b, a % b); a % b == 0 a % b a b 0 return b; b if (a < b) {
			return getGCD(b % a, a);
		}
		else return getGCD(b, a % b); a < b a b {
			return getGCD(b % a, a);
		} return getGCD(b % a, a); getGCD(b % a, a) getGCD b % a b a a return getGCD(b, a % b); getGCD(b, a % b) getGCD b a % b a b int a a int b b public class Main {

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

	public static int getGCD(int a, int b) {
		if (a % b == 0) return b;
		else if (a < b) {
			return getGCD(b % a, a);
		}
		else return getGCD(b, a % b);
	}
} public class Main {

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

	public static int getGCD(int a, int b) {
		if (a % b == 0) return b;
		else if (a < b) {
			return getGCD(b % a, a);
		}
		else return getGCD(b, a % b);
	}
} 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[] strArray = br.readLine().split(" ");
		int a = Integer.parseInt(strArray[0]);
		int b = Integer.parseInt(strArray[1]);
		if (a >= b) {
			System.out.println(getGCD(a, b));
		} else {
			System.out.println(getGCD(b, a));
		}
	}

	public static int getGCD(int a, int b) {
		if (a % b == 0) return b;
		else if (a < b) {
			return getGCD(b % a, a);
		}
		else return getGCD(b, a % b);
	}
}