import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main{
	public static void main(String[] args) throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] strArr = br.readLine().split(" ");
		long a = Long.valueOf(strArr[0]);
		long b = Long.valueOf(strArr[1]);
		System.out.println(gcd(a, b));
 	}
	
	private static long gcd(long a, long b){
		long r = a % b;
		if(r == 0)
			return b;
		else
			return gcd(b, a % b);
	}
} import java.io.BufferedReader; BufferedReader java.io import java.io.IOException; IOException java.io import java.io.InputStreamReader; InputStreamReader java.io public class Main{
	public static void main(String[] args) throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] strArr = br.readLine().split(" ");
		long a = Long.valueOf(strArr[0]);
		long b = Long.valueOf(strArr[1]);
		System.out.println(gcd(a, b));
 	}
	
	private static long gcd(long a, long b){
		long r = a % b;
		if(r == 0)
			return b;
		else
			return gcd(b, a % b);
	}
} Main public static void main(String[] args) throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] strArr = br.readLine().split(" ");
		long a = Long.valueOf(strArr[0]);
		long b = Long.valueOf(strArr[1]);
		System.out.println(gcd(a, b));
 	} main {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] strArr = br.readLine().split(" ");
		long a = Long.valueOf(strArr[0]);
		long b = Long.valueOf(strArr[1]);
		System.out.println(gcd(a, b));
 	} BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) String[] strArr = br.readLine().split(" "); strArr br.readLine().split(" ") br.readLine().split br.readLine() br.readLine br " " long a = Long.valueOf(strArr[0]); a Long.valueOf(strArr[0]) Long.valueOf Long strArr[0] strArr 0 long b = Long.valueOf(strArr[1]); b Long.valueOf(strArr[1]) Long.valueOf Long strArr[1] strArr 1 System.out.println(gcd(a, b)) System.out.println System.out System System.out gcd(a, b) gcd a b String[] args args private static long gcd(long a, long b){
		long r = a % b;
		if(r == 0)
			return b;
		else
			return gcd(b, a % b);
	} gcd {
		long r = a % b;
		if(r == 0)
			return b;
		else
			return gcd(b, a % b);
	} long r = a % b; r a % b a b if(r == 0)
			return b;
		else
			return gcd(b, a % b); r == 0 r 0 return b; b return gcd(b, a % b); gcd(b, a % b) gcd b a % b a b long a a long b b public class Main{
	public static void main(String[] args) throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] strArr = br.readLine().split(" ");
		long a = Long.valueOf(strArr[0]);
		long b = Long.valueOf(strArr[1]);
		System.out.println(gcd(a, b));
 	}
	
	private static long gcd(long a, long b){
		long r = a % b;
		if(r == 0)
			return b;
		else
			return gcd(b, a % b);
	}
} public class Main{
	public static void main(String[] args) throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] strArr = br.readLine().split(" ");
		long a = Long.valueOf(strArr[0]);
		long b = Long.valueOf(strArr[1]);
		System.out.println(gcd(a, b));
 	}
	
	private static long gcd(long a, long b){
		long r = a % b;
		if(r == 0)
			return b;
		else
			return gcd(b, a % b);
	}
} Main
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main{
	public static void main(String[] args) throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] strArr = br.readLine().split(" ");
		long a = Long.valueOf(strArr[0]);
		long b = Long.valueOf(strArr[1]);
		System.out.println(gcd(a, b));
 	}
	
	private static long gcd(long a, long b){
		long r = a % b;
		if(r == 0)
			return b;
		else
			return gcd(b, a % b);
	}
}