import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		long x = sc.nextLong();
		long y = sc.nextLong();

		sc.close();

		if(y > x) {
			long tmp;
			tmp = x;
			x = y;
			y = tmp;
		}

		long ans = gcd(x, y);

		System.out.println(ans);
	}

	private static long gcd(long x, long y) {

		if(y == 0) return x;

		return gcd(y, x%y);

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

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		long x = sc.nextLong();
		long y = sc.nextLong();

		sc.close();

		if(y > x) {
			long tmp;
			tmp = x;
			x = y;
			y = tmp;
		}

		long ans = gcd(x, y);

		System.out.println(ans);
	}

	private static long gcd(long x, long y) {

		if(y == 0) return x;

		return gcd(y, x%y);

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

		Scanner sc = new Scanner(System.in);

		long x = sc.nextLong();
		long y = sc.nextLong();

		sc.close();

		if(y > x) {
			long tmp;
			tmp = x;
			x = y;
			y = tmp;
		}

		long ans = gcd(x, y);

		System.out.println(ans);
	} main {

		Scanner sc = new Scanner(System.in);

		long x = sc.nextLong();
		long y = sc.nextLong();

		sc.close();

		if(y > x) {
			long tmp;
			tmp = x;
			x = y;
			y = tmp;
		}

		long ans = gcd(x, y);

		System.out.println(ans);
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) long x = sc.nextLong(); x sc.nextLong() sc.nextLong sc long y = sc.nextLong(); y sc.nextLong() sc.nextLong sc sc.close() sc.close sc if(y > x) {
			long tmp;
			tmp = x;
			x = y;
			y = tmp;
		} y > x y x {
			long tmp;
			tmp = x;
			x = y;
			y = tmp;
		} long tmp; tmp tmp = x tmp x x = y x y y = tmp y tmp long ans = gcd(x, y); ans gcd(x, y) gcd x y System.out.println(ans) System.out.println System.out System System.out ans String[] args args private static long gcd(long x, long y) {

		if(y == 0) return x;

		return gcd(y, x%y);

	} gcd {

		if(y == 0) return x;

		return gcd(y, x%y);

	} if(y == 0) return x; y == 0 y 0 return x; x return gcd(y, x%y); gcd(y, x%y) gcd y x%y x y long x x long y y public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		long x = sc.nextLong();
		long y = sc.nextLong();

		sc.close();

		if(y > x) {
			long tmp;
			tmp = x;
			x = y;
			y = tmp;
		}

		long ans = gcd(x, y);

		System.out.println(ans);
	}

	private static long gcd(long x, long y) {

		if(y == 0) return x;

		return gcd(y, x%y);

	}
} public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		long x = sc.nextLong();
		long y = sc.nextLong();

		sc.close();

		if(y > x) {
			long tmp;
			tmp = x;
			x = y;
			y = tmp;
		}

		long ans = gcd(x, y);

		System.out.println(ans);
	}

	private static long gcd(long x, long y) {

		if(y == 0) return x;

		return gcd(y, x%y);

	}
} Main
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		long x = sc.nextLong();
		long y = sc.nextLong();

		sc.close();

		if(y > x) {
			long tmp;
			tmp = x;
			x = y;
			y = tmp;
		}

		long ans = gcd(x, y);

		System.out.println(ans);
	}

	private static long gcd(long x, long y) {

		if(y == 0) return x;

		return gcd(y, x%y);

	}
}