import java.util.Scanner;

public class Main {

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

		Scanner sc = new Scanner(System.in);
	    StringBuilder out;

		int a = sc.nextInt();
		int b = sc.nextInt();

		int gcd = getGCD(a, b);
		System.out.println(gcd);

	}


	static int getGCD(int a, int b) {

		int gcd = 0;
		int x = Math.max(a, b);
		int y = Math.min(a, b);
		int rest = x % y;

		if(rest == 0) {
			return y;
		}

		for(int i = rest; i > 0; i--) {

			if(y % i == 0 && rest % i == 0) {
				return i;
			}
		}

		return 0;
	}
} import java.util.Scanner; Scanner java.util public class Main {

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

		Scanner sc = new Scanner(System.in);
	    StringBuilder out;

		int a = sc.nextInt();
		int b = sc.nextInt();

		int gcd = getGCD(a, b);
		System.out.println(gcd);

	}


	static int getGCD(int a, int b) {

		int gcd = 0;
		int x = Math.max(a, b);
		int y = Math.min(a, b);
		int rest = x % y;

		if(rest == 0) {
			return y;
		}

		for(int i = rest; i > 0; i--) {

			if(y % i == 0 && rest % i == 0) {
				return i;
			}
		}

		return 0;
	}
} Main public static void main(String[] args) throws Exception {

		Scanner sc = new Scanner(System.in);
	    StringBuilder out;

		int a = sc.nextInt();
		int b = sc.nextInt();

		int gcd = getGCD(a, b);
		System.out.println(gcd);

	} main {

		Scanner sc = new Scanner(System.in);
	    StringBuilder out;

		int a = sc.nextInt();
		int b = sc.nextInt();

		int gcd = getGCD(a, b);
		System.out.println(gcd);

	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) StringBuilder out; out int a = sc.nextInt(); a sc.nextInt() sc.nextInt sc int b = sc.nextInt(); b sc.nextInt() sc.nextInt sc int gcd = getGCD(a, b); gcd getGCD(a, b) getGCD a b System.out.println(gcd) System.out.println System.out System System.out gcd String[] args args static int getGCD(int a, int b) {

		int gcd = 0;
		int x = Math.max(a, b);
		int y = Math.min(a, b);
		int rest = x % y;

		if(rest == 0) {
			return y;
		}

		for(int i = rest; i > 0; i--) {

			if(y % i == 0 && rest % i == 0) {
				return i;
			}
		}

		return 0;
	} getGCD {

		int gcd = 0;
		int x = Math.max(a, b);
		int y = Math.min(a, b);
		int rest = x % y;

		if(rest == 0) {
			return y;
		}

		for(int i = rest; i > 0; i--) {

			if(y % i == 0 && rest % i == 0) {
				return i;
			}
		}

		return 0;
	} int gcd = 0; gcd 0 int x = Math.max(a, b); x Math.max(a, b) Math.max Math a b int y = Math.min(a, b); y Math.min(a, b) Math.min Math a b int rest = x % y; rest x % y x y if(rest == 0) {
			return y;
		} rest == 0 rest 0 {
			return y;
		} return y; y for(int i = rest; i > 0; i--) {

			if(y % i == 0 && rest % i == 0) {
				return i;
			}
		} int i = rest; int i = rest; i rest i > 0 i 0 i-- i-- i {

			if(y % i == 0 && rest % i == 0) {
				return i;
			}
		} {

			if(y % i == 0 && rest % i == 0) {
				return i;
			}
		} if(y % i == 0 && rest % i == 0) {
				return i;
			} y % i == 0 && rest % i == 0 y % i == 0 y % i y i 0 rest % i == 0 rest % i rest i 0 {
				return i;
			} return i; i return 0; 0 int a a int b b public class Main {

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

		Scanner sc = new Scanner(System.in);
	    StringBuilder out;

		int a = sc.nextInt();
		int b = sc.nextInt();

		int gcd = getGCD(a, b);
		System.out.println(gcd);

	}


	static int getGCD(int a, int b) {

		int gcd = 0;
		int x = Math.max(a, b);
		int y = Math.min(a, b);
		int rest = x % y;

		if(rest == 0) {
			return y;
		}

		for(int i = rest; i > 0; i--) {

			if(y % i == 0 && rest % i == 0) {
				return i;
			}
		}

		return 0;
	}
} public class Main {

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

		Scanner sc = new Scanner(System.in);
	    StringBuilder out;

		int a = sc.nextInt();
		int b = sc.nextInt();

		int gcd = getGCD(a, b);
		System.out.println(gcd);

	}


	static int getGCD(int a, int b) {

		int gcd = 0;
		int x = Math.max(a, b);
		int y = Math.min(a, b);
		int rest = x % y;

		if(rest == 0) {
			return y;
		}

		for(int i = rest; i > 0; i--) {

			if(y % i == 0 && rest % i == 0) {
				return i;
			}
		}

		return 0;
	}
} Main
import java.util.Scanner;

public class Main {

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

		Scanner sc = new Scanner(System.in);
	    StringBuilder out;

		int a = sc.nextInt();
		int b = sc.nextInt();

		int gcd = getGCD(a, b);
		System.out.println(gcd);

	}


	static int getGCD(int a, int b) {

		int gcd = 0;
		int x = Math.max(a, b);
		int y = Math.min(a, b);
		int rest = x % y;

		if(rest == 0) {
			return y;
		}

		for(int i = rest; i > 0; i--) {

			if(y % i == 0 && rest % i == 0) {
				return i;
			}
		}

		return 0;
	}
}
