import java.math.BigInteger;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

class Main
{
	public static void main(String[] args)
	{
		Scanner scan=new Scanner(System.in);
		BigInteger bi1=new BigInteger(scan.next());
		BigInteger bi2=new BigInteger(scan.next());
		System.out.println(bi1.gcd(bi2));
	}
} import java.math.BigInteger; BigInteger java.math import java.util.ArrayList; ArrayList java.util import java.util.HashMap; HashMap java.util import java.util.Map; Map java.util import java.util.Scanner; Scanner java.util class Main
{
	public static void main(String[] args)
	{
		Scanner scan=new Scanner(System.in);
		BigInteger bi1=new BigInteger(scan.next());
		BigInteger bi2=new BigInteger(scan.next());
		System.out.println(bi1.gcd(bi2));
	}
} Main public static void main(String[] args)
	{
		Scanner scan=new Scanner(System.in);
		BigInteger bi1=new BigInteger(scan.next());
		BigInteger bi2=new BigInteger(scan.next());
		System.out.println(bi1.gcd(bi2));
	} main {
		Scanner scan=new Scanner(System.in);
		BigInteger bi1=new BigInteger(scan.next());
		BigInteger bi2=new BigInteger(scan.next());
		System.out.println(bi1.gcd(bi2));
	} Scanner scan=new Scanner(System.in); scan new Scanner(System.in) BigInteger bi1=new BigInteger(scan.next()); bi1 new BigInteger(scan.next()) BigInteger bi2=new BigInteger(scan.next()); bi2 new BigInteger(scan.next()) System.out.println(bi1.gcd(bi2)) System.out.println System.out System System.out bi1.gcd(bi2) bi1.gcd bi1 bi2 String[] args args
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

class Main
{
	public static void main(String[] args)
	{
		Scanner scan=new Scanner(System.in);
		BigInteger bi1=new BigInteger(scan.next());
		BigInteger bi2=new BigInteger(scan.next());
		System.out.println(bi1.gcd(bi2));
	}
}