import java.util.*;

class Main {
	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		int a = stdIn.nextInt();
		int b = stdIn.nextInt();
		System.out.println(euclid(a,b));
	}

	static int euclid(int a,int b){
		if (b == 0) {
			return a;
		}else {
			return euclid(b,a%b);
		}
	}
} import java.util.*; util.* java class Main {
	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		int a = stdIn.nextInt();
		int b = stdIn.nextInt();
		System.out.println(euclid(a,b));
	}

	static int euclid(int a,int b){
		if (b == 0) {
			return a;
		}else {
			return euclid(b,a%b);
		}
	}
} Main public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		int a = stdIn.nextInt();
		int b = stdIn.nextInt();
		System.out.println(euclid(a,b));
	} main {
		Scanner stdIn = new Scanner(System.in);
		int a = stdIn.nextInt();
		int b = stdIn.nextInt();
		System.out.println(euclid(a,b));
	} Scanner stdIn = new Scanner(System.in); stdIn new Scanner(System.in) int a = stdIn.nextInt(); a stdIn.nextInt() stdIn.nextInt stdIn int b = stdIn.nextInt(); b stdIn.nextInt() stdIn.nextInt stdIn System.out.println(euclid(a,b)) System.out.println System.out System System.out euclid(a,b) euclid a b String[] args args static int euclid(int a,int b){
		if (b == 0) {
			return a;
		}else {
			return euclid(b,a%b);
		}
	} euclid {
		if (b == 0) {
			return a;
		}else {
			return euclid(b,a%b);
		}
	} if (b == 0) {
			return a;
		}else {
			return euclid(b,a%b);
		} b == 0 b 0 {
			return a;
		} return a; a {
			return euclid(b,a%b);
		} return euclid(b,a%b); euclid(b,a%b) euclid b a%b a b int a a int b b
import java.util.*;

class Main {
	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		int a = stdIn.nextInt();
		int b = stdIn.nextInt();
		System.out.println(euclid(a,b));
	}

	static int euclid(int a,int b){
		if (b == 0) {
			return a;
		}else {
			return euclid(b,a%b);
		}
	}
}