import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		int y = sc.nextInt();
		int ans = gcd(x, y);
		System.out.println(ans);
	}

	public static int gcd(int x, int y) {
		int temp;
		int r;
		if (y > x) {
			temp = x;
			x = y;
			y = temp;
		}
		while (y > 0) {
			r = x % y;
			x = y;
			y = r;
		}
		return x;
	}
} import java.util.Scanner; Scanner java.util public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		int y = sc.nextInt();
		int ans = gcd(x, y);
		System.out.println(ans);
	}

	public static int gcd(int x, int y) {
		int temp;
		int r;
		if (y > x) {
			temp = x;
			x = y;
			y = temp;
		}
		while (y > 0) {
			r = x % y;
			x = y;
			y = r;
		}
		return x;
	}
} Main public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		int y = sc.nextInt();
		int ans = gcd(x, y);
		System.out.println(ans);
	} main {
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		int y = sc.nextInt();
		int ans = gcd(x, y);
		System.out.println(ans);
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int x = sc.nextInt(); x sc.nextInt() sc.nextInt sc int y = sc.nextInt(); y sc.nextInt() sc.nextInt sc int 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 public static int gcd(int x, int y) {
		int temp;
		int r;
		if (y > x) {
			temp = x;
			x = y;
			y = temp;
		}
		while (y > 0) {
			r = x % y;
			x = y;
			y = r;
		}
		return x;
	} gcd {
		int temp;
		int r;
		if (y > x) {
			temp = x;
			x = y;
			y = temp;
		}
		while (y > 0) {
			r = x % y;
			x = y;
			y = r;
		}
		return x;
	} int temp; temp int r; r if (y > x) {
			temp = x;
			x = y;
			y = temp;
		} y > x y x {
			temp = x;
			x = y;
			y = temp;
		} temp = x temp x x = y x y y = temp y temp while (y > 0) {
			r = x % y;
			x = y;
			y = r;
		} y > 0 y 0 {
			r = x % y;
			x = y;
			y = r;
		} r = x % y r x % y x y x = y x y y = r y r return x; x int x x int y y public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		int y = sc.nextInt();
		int ans = gcd(x, y);
		System.out.println(ans);
	}

	public static int gcd(int x, int y) {
		int temp;
		int r;
		if (y > x) {
			temp = x;
			x = y;
			y = temp;
		}
		while (y > 0) {
			r = x % y;
			x = y;
			y = r;
		}
		return x;
	}
} public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		int y = sc.nextInt();
		int ans = gcd(x, y);
		System.out.println(ans);
	}

	public static int gcd(int x, int y) {
		int temp;
		int r;
		if (y > x) {
			temp = x;
			x = y;
			y = temp;
		}
		while (y > 0) {
			r = x % y;
			x = y;
			y = r;
		}
		return x;
	}
} Main
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		int y = sc.nextInt();
		int ans = gcd(x, y);
		System.out.println(ans);
	}

	public static int gcd(int x, int y) {
		int temp;
		int r;
		if (y > x) {
			temp = x;
			x = y;
			y = temp;
		}
		while (y > 0) {
			r = x % y;
			x = y;
			y = r;
		}
		return x;
	}
}
