import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int a=sc.nextInt();
		int b=sc.nextInt();

		int x=Math.max(a, b);
		int y=Math.min(a, b);

		while (x%y!=0) {
			int z=x%y;
			x=y;
			y=z;
		}
		System.out.println(y);
	}

}
 import java.util.Scanner; Scanner java.util public class Main {
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int a=sc.nextInt();
		int b=sc.nextInt();

		int x=Math.max(a, b);
		int y=Math.min(a, b);

		while (x%y!=0) {
			int z=x%y;
			x=y;
			y=z;
		}
		System.out.println(y);
	}

} Main public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int a=sc.nextInt();
		int b=sc.nextInt();

		int x=Math.max(a, b);
		int y=Math.min(a, b);

		while (x%y!=0) {
			int z=x%y;
			x=y;
			y=z;
		}
		System.out.println(y);
	} main {
		Scanner sc=new Scanner(System.in);
		int a=sc.nextInt();
		int b=sc.nextInt();

		int x=Math.max(a, b);
		int y=Math.min(a, b);

		while (x%y!=0) {
			int z=x%y;
			x=y;
			y=z;
		}
		System.out.println(y);
	} Scanner sc=new Scanner(System.in); sc new Scanner(System.in) int a=sc.nextInt(); a sc.nextInt() sc.nextInt sc int b=sc.nextInt(); b sc.nextInt() sc.nextInt sc 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 while (x%y!=0) {
			int z=x%y;
			x=y;
			y=z;
		} x%y!=0 x%y x y 0 {
			int z=x%y;
			x=y;
			y=z;
		} int z=x%y; z x%y x y x=y x y y=z y z System.out.println(y) System.out.println System.out System System.out y String[] args args public class Main {
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int a=sc.nextInt();
		int b=sc.nextInt();

		int x=Math.max(a, b);
		int y=Math.min(a, b);

		while (x%y!=0) {
			int z=x%y;
			x=y;
			y=z;
		}
		System.out.println(y);
	}

} public class Main {
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int a=sc.nextInt();
		int b=sc.nextInt();

		int x=Math.max(a, b);
		int y=Math.min(a, b);

		while (x%y!=0) {
			int z=x%y;
			x=y;
			y=z;
		}
		System.out.println(y);
	}

} Main
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int a=sc.nextInt();
		int b=sc.nextInt();

		int x=Math.max(a, b);
		int y=Math.min(a, b);

		while (x%y!=0) {
			int z=x%y;
			x=y;
			y=z;
		}
		System.out.println(y);
	}

}

