import java.util.Scanner;
public class Main {

	public static void main (String [] args) {
		Scanner in = new Scanner(System.in);
		int a = in.nextInt();
		int b = in.nextInt();
		
		while (b > 0) {
			int temp = a;
			a = b;
			b = temp % b;
		}
		
		System.out.println(a);
	}
} import java.util.Scanner; Scanner java.util public class Main {

	public static void main (String [] args) {
		Scanner in = new Scanner(System.in);
		int a = in.nextInt();
		int b = in.nextInt();
		
		while (b > 0) {
			int temp = a;
			a = b;
			b = temp % b;
		}
		
		System.out.println(a);
	}
} Main public static void main (String [] args) {
		Scanner in = new Scanner(System.in);
		int a = in.nextInt();
		int b = in.nextInt();
		
		while (b > 0) {
			int temp = a;
			a = b;
			b = temp % b;
		}
		
		System.out.println(a);
	} main {
		Scanner in = new Scanner(System.in);
		int a = in.nextInt();
		int b = in.nextInt();
		
		while (b > 0) {
			int temp = a;
			a = b;
			b = temp % b;
		}
		
		System.out.println(a);
	} Scanner in = new Scanner(System.in); in new Scanner(System.in) int a = in.nextInt(); a in.nextInt() in.nextInt in int b = in.nextInt(); b in.nextInt() in.nextInt in while (b > 0) {
			int temp = a;
			a = b;
			b = temp % b;
		} b > 0 b 0 {
			int temp = a;
			a = b;
			b = temp % b;
		} int temp = a; temp a a = b a b b = temp % b b temp % b temp b System.out.println(a) System.out.println System.out System System.out a String [] args args public class Main {

	public static void main (String [] args) {
		Scanner in = new Scanner(System.in);
		int a = in.nextInt();
		int b = in.nextInt();
		
		while (b > 0) {
			int temp = a;
			a = b;
			b = temp % b;
		}
		
		System.out.println(a);
	}
} public class Main {

	public static void main (String [] args) {
		Scanner in = new Scanner(System.in);
		int a = in.nextInt();
		int b = in.nextInt();
		
		while (b > 0) {
			int temp = a;
			a = b;
			b = temp % b;
		}
		
		System.out.println(a);
	}
} Main
import java.util.Scanner;
public class Main {

	public static void main (String [] args) {
		Scanner in = new Scanner(System.in);
		int a = in.nextInt();
		int b = in.nextInt();
		
		while (b > 0) {
			int temp = a;
			a = b;
			b = temp % b;
		}
		
		System.out.println(a);
	}
}
