import java.util.Scanner;

public class Main{
	public static int x;
	public static int y;
	public static int z;

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		x= sc.nextInt();
		y = sc.nextInt();
		if(x > y){
			solve(x,y);
		}
		else{
			solve(y,x);
		}
		System.out.println(z);

	}

	public static void solve(int big,int small){
		z = big % small;
		if (z == 0){
			z = small;
		}
		else{
			solve(small,z);
		}

	}

} import java.util.Scanner; Scanner java.util public class Main{
	public static int x;
	public static int y;
	public static int z;

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		x= sc.nextInt();
		y = sc.nextInt();
		if(x > y){
			solve(x,y);
		}
		else{
			solve(y,x);
		}
		System.out.println(z);

	}

	public static void solve(int big,int small){
		z = big % small;
		if (z == 0){
			z = small;
		}
		else{
			solve(small,z);
		}

	}

} Main public static int x; x public static int y; y public static int z; z public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		x= sc.nextInt();
		y = sc.nextInt();
		if(x > y){
			solve(x,y);
		}
		else{
			solve(y,x);
		}
		System.out.println(z);

	} main {
		Scanner sc = new Scanner(System.in);
		x= sc.nextInt();
		y = sc.nextInt();
		if(x > y){
			solve(x,y);
		}
		else{
			solve(y,x);
		}
		System.out.println(z);

	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) x= sc.nextInt() x sc.nextInt() sc.nextInt sc y = sc.nextInt() y sc.nextInt() sc.nextInt sc if(x > y){
			solve(x,y);
		}
		else{
			solve(y,x);
		} x > y x y {
			solve(x,y);
		} solve(x,y) solve x y {
			solve(y,x);
		} solve(y,x) solve y x System.out.println(z) System.out.println System.out System System.out z String[] args args public static void solve(int big,int small){
		z = big % small;
		if (z == 0){
			z = small;
		}
		else{
			solve(small,z);
		}

	} solve {
		z = big % small;
		if (z == 0){
			z = small;
		}
		else{
			solve(small,z);
		}

	} z = big % small z big % small big small if (z == 0){
			z = small;
		}
		else{
			solve(small,z);
		} z == 0 z 0 {
			z = small;
		} z = small z small {
			solve(small,z);
		} solve(small,z) solve small z int big big int small small public class Main{
	public static int x;
	public static int y;
	public static int z;

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		x= sc.nextInt();
		y = sc.nextInt();
		if(x > y){
			solve(x,y);
		}
		else{
			solve(y,x);
		}
		System.out.println(z);

	}

	public static void solve(int big,int small){
		z = big % small;
		if (z == 0){
			z = small;
		}
		else{
			solve(small,z);
		}

	}

} public class Main{
	public static int x;
	public static int y;
	public static int z;

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		x= sc.nextInt();
		y = sc.nextInt();
		if(x > y){
			solve(x,y);
		}
		else{
			solve(y,x);
		}
		System.out.println(z);

	}

	public static void solve(int big,int small){
		z = big % small;
		if (z == 0){
			z = small;
		}
		else{
			solve(small,z);
		}

	}

} Main
import java.util.Scanner;

public class Main{
	public static int x;
	public static int y;
	public static int z;

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		x= sc.nextInt();
		y = sc.nextInt();
		if(x > y){
			solve(x,y);
		}
		else{
			solve(y,x);
		}
		System.out.println(z);

	}

	public static void solve(int big,int small){
		z = big % small;
		if (z == 0){
			z = small;
		}
		else{
			solve(small,z);
		}

	}

}