import java.util.Scanner;

public class Main{
    public static void main(String[] args){
	Scanner sc = new Scanner(System.in);
	int n1 = sc.nextInt();
	int n2 = sc.nextInt();
	System.out.println(euc(n1,n2));
    }
    private static int euc(int n1, int n2){
	if(n1 < n2) return euc(n2,n1);
	if(n2 == 0) return n1;
	return euc(n2,n1%n2);
    }
}
 import java.util.Scanner; Scanner java.util public class Main{
    public static void main(String[] args){
	Scanner sc = new Scanner(System.in);
	int n1 = sc.nextInt();
	int n2 = sc.nextInt();
	System.out.println(euc(n1,n2));
    }
    private static int euc(int n1, int n2){
	if(n1 < n2) return euc(n2,n1);
	if(n2 == 0) return n1;
	return euc(n2,n1%n2);
    }
} Main public static void main(String[] args){
	Scanner sc = new Scanner(System.in);
	int n1 = sc.nextInt();
	int n2 = sc.nextInt();
	System.out.println(euc(n1,n2));
    } main {
	Scanner sc = new Scanner(System.in);
	int n1 = sc.nextInt();
	int n2 = sc.nextInt();
	System.out.println(euc(n1,n2));
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int n1 = sc.nextInt(); n1 sc.nextInt() sc.nextInt sc int n2 = sc.nextInt(); n2 sc.nextInt() sc.nextInt sc System.out.println(euc(n1,n2)) System.out.println System.out System System.out euc(n1,n2) euc n1 n2 String[] args args private static int euc(int n1, int n2){
	if(n1 < n2) return euc(n2,n1);
	if(n2 == 0) return n1;
	return euc(n2,n1%n2);
    } euc {
	if(n1 < n2) return euc(n2,n1);
	if(n2 == 0) return n1;
	return euc(n2,n1%n2);
    } if(n1 < n2) return euc(n2,n1); n1 < n2 n1 n2 return euc(n2,n1); euc(n2,n1) euc n2 n1 if(n2 == 0) return n1; n2 == 0 n2 0 return n1; n1 return euc(n2,n1%n2); euc(n2,n1%n2) euc n2 n1%n2 n1 n2 int n1 n1 int n2 n2 public class Main{
    public static void main(String[] args){
	Scanner sc = new Scanner(System.in);
	int n1 = sc.nextInt();
	int n2 = sc.nextInt();
	System.out.println(euc(n1,n2));
    }
    private static int euc(int n1, int n2){
	if(n1 < n2) return euc(n2,n1);
	if(n2 == 0) return n1;
	return euc(n2,n1%n2);
    }
} public class Main{
    public static void main(String[] args){
	Scanner sc = new Scanner(System.in);
	int n1 = sc.nextInt();
	int n2 = sc.nextInt();
	System.out.println(euc(n1,n2));
    }
    private static int euc(int n1, int n2){
	if(n1 < n2) return euc(n2,n1);
	if(n2 == 0) return n1;
	return euc(n2,n1%n2);
    }
} Main
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
	Scanner sc = new Scanner(System.in);
	int n1 = sc.nextInt();
	int n2 = sc.nextInt();
	System.out.println(euc(n1,n2));
    }
    private static int euc(int n1, int n2){
	if(n1 < n2) return euc(n2,n1);
	if(n2 == 0) return n1;
	return euc(n2,n1%n2);
    }
}

