import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		long x = scan.nextLong();
		long y = scan.nextLong();
		scan.close();
		long smaller = Math.min(x, y);
		long bigger = Math.max(x, y);
		System.out.println(GreatestCommonDivisor(bigger, smaller));
	}

	static long GreatestCommonDivisor(long x, long y){
		long mod = Math.floorMod(x, y);
		if(mod == 0){
			return y;
		}else{
			x = Math.max(y, mod);
			y = Math.min(y, mod);
			return GreatestCommonDivisor(x, y);
		}
	}
} import java.util.Scanner; Scanner java.util public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		long x = scan.nextLong();
		long y = scan.nextLong();
		scan.close();
		long smaller = Math.min(x, y);
		long bigger = Math.max(x, y);
		System.out.println(GreatestCommonDivisor(bigger, smaller));
	}

	static long GreatestCommonDivisor(long x, long y){
		long mod = Math.floorMod(x, y);
		if(mod == 0){
			return y;
		}else{
			x = Math.max(y, mod);
			y = Math.min(y, mod);
			return GreatestCommonDivisor(x, y);
		}
	}
} Main public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		long x = scan.nextLong();
		long y = scan.nextLong();
		scan.close();
		long smaller = Math.min(x, y);
		long bigger = Math.max(x, y);
		System.out.println(GreatestCommonDivisor(bigger, smaller));
	} main {
		Scanner scan = new Scanner(System.in);
		long x = scan.nextLong();
		long y = scan.nextLong();
		scan.close();
		long smaller = Math.min(x, y);
		long bigger = Math.max(x, y);
		System.out.println(GreatestCommonDivisor(bigger, smaller));
	} Scanner scan = new Scanner(System.in); scan new Scanner(System.in) long x = scan.nextLong(); x scan.nextLong() scan.nextLong scan long y = scan.nextLong(); y scan.nextLong() scan.nextLong scan scan.close() scan.close scan long smaller = Math.min(x, y); smaller Math.min(x, y) Math.min Math x y long bigger = Math.max(x, y); bigger Math.max(x, y) Math.max Math x y System.out.println(GreatestCommonDivisor(bigger, smaller)) System.out.println System.out System System.out GreatestCommonDivisor(bigger, smaller) GreatestCommonDivisor bigger smaller String[] args args static long GreatestCommonDivisor(long x, long y){
		long mod = Math.floorMod(x, y);
		if(mod == 0){
			return y;
		}else{
			x = Math.max(y, mod);
			y = Math.min(y, mod);
			return GreatestCommonDivisor(x, y);
		}
	} GreatestCommonDivisor {
		long mod = Math.floorMod(x, y);
		if(mod == 0){
			return y;
		}else{
			x = Math.max(y, mod);
			y = Math.min(y, mod);
			return GreatestCommonDivisor(x, y);
		}
	} long mod = Math.floorMod(x, y); mod Math.floorMod(x, y) Math.floorMod Math x y if(mod == 0){
			return y;
		}else{
			x = Math.max(y, mod);
			y = Math.min(y, mod);
			return GreatestCommonDivisor(x, y);
		} mod == 0 mod 0 {
			return y;
		} return y; y {
			x = Math.max(y, mod);
			y = Math.min(y, mod);
			return GreatestCommonDivisor(x, y);
		} x = Math.max(y, mod) x Math.max(y, mod) Math.max Math y mod y = Math.min(y, mod) y Math.min(y, mod) Math.min Math y mod return GreatestCommonDivisor(x, y); GreatestCommonDivisor(x, y) GreatestCommonDivisor x y long x x long y y public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		long x = scan.nextLong();
		long y = scan.nextLong();
		scan.close();
		long smaller = Math.min(x, y);
		long bigger = Math.max(x, y);
		System.out.println(GreatestCommonDivisor(bigger, smaller));
	}

	static long GreatestCommonDivisor(long x, long y){
		long mod = Math.floorMod(x, y);
		if(mod == 0){
			return y;
		}else{
			x = Math.max(y, mod);
			y = Math.min(y, mod);
			return GreatestCommonDivisor(x, y);
		}
	}
} public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		long x = scan.nextLong();
		long y = scan.nextLong();
		scan.close();
		long smaller = Math.min(x, y);
		long bigger = Math.max(x, y);
		System.out.println(GreatestCommonDivisor(bigger, smaller));
	}

	static long GreatestCommonDivisor(long x, long y){
		long mod = Math.floorMod(x, y);
		if(mod == 0){
			return y;
		}else{
			x = Math.max(y, mod);
			y = Math.min(y, mod);
			return GreatestCommonDivisor(x, y);
		}
	}
} Main
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		long x = scan.nextLong();
		long y = scan.nextLong();
		scan.close();
		long smaller = Math.min(x, y);
		long bigger = Math.max(x, y);
		System.out.println(GreatestCommonDivisor(bigger, smaller));
	}

	static long GreatestCommonDivisor(long x, long y){
		long mod = Math.floorMod(x, y);
		if(mod == 0){
			return y;
		}else{
			x = Math.max(y, mod);
			y = Math.min(y, mod);
			return GreatestCommonDivisor(x, y);
		}
	}
}