import java.util.Scanner;
public class Main {
	public static void main(String args[]) {
		Scanner scan = new Scanner(System.in);
		int x = scan.nextInt();
		int y = scan.nextInt();
		while(true){
			int rem = 0;
			if (x > y) {
				rem = x % y;
				x = rem;
				if (rem == 0) {
					System.out.println(y);
					return;
				}
			} else {
				rem = y % x;
				y = rem;
				if (rem == 0) {
					System.out.println(x);
					return;
				}
			}
		}
	}
} import java.util.Scanner; Scanner java.util public class Main {
	public static void main(String args[]) {
		Scanner scan = new Scanner(System.in);
		int x = scan.nextInt();
		int y = scan.nextInt();
		while(true){
			int rem = 0;
			if (x > y) {
				rem = x % y;
				x = rem;
				if (rem == 0) {
					System.out.println(y);
					return;
				}
			} else {
				rem = y % x;
				y = rem;
				if (rem == 0) {
					System.out.println(x);
					return;
				}
			}
		}
	}
} Main public static void main(String args[]) {
		Scanner scan = new Scanner(System.in);
		int x = scan.nextInt();
		int y = scan.nextInt();
		while(true){
			int rem = 0;
			if (x > y) {
				rem = x % y;
				x = rem;
				if (rem == 0) {
					System.out.println(y);
					return;
				}
			} else {
				rem = y % x;
				y = rem;
				if (rem == 0) {
					System.out.println(x);
					return;
				}
			}
		}
	} main {
		Scanner scan = new Scanner(System.in);
		int x = scan.nextInt();
		int y = scan.nextInt();
		while(true){
			int rem = 0;
			if (x > y) {
				rem = x % y;
				x = rem;
				if (rem == 0) {
					System.out.println(y);
					return;
				}
			} else {
				rem = y % x;
				y = rem;
				if (rem == 0) {
					System.out.println(x);
					return;
				}
			}
		}
	} Scanner scan = new Scanner(System.in); scan new Scanner(System.in) int x = scan.nextInt(); x scan.nextInt() scan.nextInt scan int y = scan.nextInt(); y scan.nextInt() scan.nextInt scan while(true){
			int rem = 0;
			if (x > y) {
				rem = x % y;
				x = rem;
				if (rem == 0) {
					System.out.println(y);
					return;
				}
			} else {
				rem = y % x;
				y = rem;
				if (rem == 0) {
					System.out.println(x);
					return;
				}
			}
		} true {
			int rem = 0;
			if (x > y) {
				rem = x % y;
				x = rem;
				if (rem == 0) {
					System.out.println(y);
					return;
				}
			} else {
				rem = y % x;
				y = rem;
				if (rem == 0) {
					System.out.println(x);
					return;
				}
			}
		} int rem = 0; rem 0 if (x > y) {
				rem = x % y;
				x = rem;
				if (rem == 0) {
					System.out.println(y);
					return;
				}
			} else {
				rem = y % x;
				y = rem;
				if (rem == 0) {
					System.out.println(x);
					return;
				}
			} x > y x y {
				rem = x % y;
				x = rem;
				if (rem == 0) {
					System.out.println(y);
					return;
				}
			} rem = x % y rem x % y x y x = rem x rem if (rem == 0) {
					System.out.println(y);
					return;
				} rem == 0 rem 0 {
					System.out.println(y);
					return;
				} System.out.println(y) System.out.println System.out System System.out y return; {
				rem = y % x;
				y = rem;
				if (rem == 0) {
					System.out.println(x);
					return;
				}
			} rem = y % x rem y % x y x y = rem y rem if (rem == 0) {
					System.out.println(x);
					return;
				} rem == 0 rem 0 {
					System.out.println(x);
					return;
				} System.out.println(x) System.out.println System.out System System.out x return; String args[] args public class Main {
	public static void main(String args[]) {
		Scanner scan = new Scanner(System.in);
		int x = scan.nextInt();
		int y = scan.nextInt();
		while(true){
			int rem = 0;
			if (x > y) {
				rem = x % y;
				x = rem;
				if (rem == 0) {
					System.out.println(y);
					return;
				}
			} else {
				rem = y % x;
				y = rem;
				if (rem == 0) {
					System.out.println(x);
					return;
				}
			}
		}
	}
} public class Main {
	public static void main(String args[]) {
		Scanner scan = new Scanner(System.in);
		int x = scan.nextInt();
		int y = scan.nextInt();
		while(true){
			int rem = 0;
			if (x > y) {
				rem = x % y;
				x = rem;
				if (rem == 0) {
					System.out.println(y);
					return;
				}
			} else {
				rem = y % x;
				y = rem;
				if (rem == 0) {
					System.out.println(x);
					return;
				}
			}
		}
	}
} Main
import java.util.Scanner;
public class Main {
	public static void main(String args[]) {
		Scanner scan = new Scanner(System.in);
		int x = scan.nextInt();
		int y = scan.nextInt();
		while(true){
			int rem = 0;
			if (x > y) {
				rem = x % y;
				x = rem;
				if (rem == 0) {
					System.out.println(y);
					return;
				}
			} else {
				rem = y % x;
				y = rem;
				if (rem == 0) {
					System.out.println(x);
					return;
				}
			}
		}
	}
}
