import java.util.Scanner;
public class Main {
	
	public static int getGcd(int a, int b) {
		if (a == b)
			return b;
		int bigger = Math.max(a, b);
		int smaller = Math.min(a, b);
		int modded = bigger % smaller;
		if (modded == 0)
			return smaller;
		return getGcd(smaller, bigger % smaller);
	}

	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		int a = s.nextInt();
		int b = s.nextInt();
		
		int result = getGcd(a, b);
		System.out.println(result);
	}
} import java.util.Scanner; Scanner java.util public class Main {
	
	public static int getGcd(int a, int b) {
		if (a == b)
			return b;
		int bigger = Math.max(a, b);
		int smaller = Math.min(a, b);
		int modded = bigger % smaller;
		if (modded == 0)
			return smaller;
		return getGcd(smaller, bigger % smaller);
	}

	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		int a = s.nextInt();
		int b = s.nextInt();
		
		int result = getGcd(a, b);
		System.out.println(result);
	}
} Main public static int getGcd(int a, int b) {
		if (a == b)
			return b;
		int bigger = Math.max(a, b);
		int smaller = Math.min(a, b);
		int modded = bigger % smaller;
		if (modded == 0)
			return smaller;
		return getGcd(smaller, bigger % smaller);
	} getGcd {
		if (a == b)
			return b;
		int bigger = Math.max(a, b);
		int smaller = Math.min(a, b);
		int modded = bigger % smaller;
		if (modded == 0)
			return smaller;
		return getGcd(smaller, bigger % smaller);
	} if (a == b)
			return b; a == b a b return b; b int bigger = Math.max(a, b); bigger Math.max(a, b) Math.max Math a b int smaller = Math.min(a, b); smaller Math.min(a, b) Math.min Math a b int modded = bigger % smaller; modded bigger % smaller bigger smaller if (modded == 0)
			return smaller; modded == 0 modded 0 return smaller; smaller return getGcd(smaller, bigger % smaller); getGcd(smaller, bigger % smaller) getGcd smaller bigger % smaller bigger smaller int a a int b b public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		int a = s.nextInt();
		int b = s.nextInt();
		
		int result = getGcd(a, b);
		System.out.println(result);
	} main {
		Scanner s = new Scanner(System.in);
		int a = s.nextInt();
		int b = s.nextInt();
		
		int result = getGcd(a, b);
		System.out.println(result);
	} Scanner s = new Scanner(System.in); s new Scanner(System.in) int a = s.nextInt(); a s.nextInt() s.nextInt s int b = s.nextInt(); b s.nextInt() s.nextInt s int result = getGcd(a, b); result getGcd(a, b) getGcd a b System.out.println(result) System.out.println System.out System System.out result String[] args args public class Main {
	
	public static int getGcd(int a, int b) {
		if (a == b)
			return b;
		int bigger = Math.max(a, b);
		int smaller = Math.min(a, b);
		int modded = bigger % smaller;
		if (modded == 0)
			return smaller;
		return getGcd(smaller, bigger % smaller);
	}

	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		int a = s.nextInt();
		int b = s.nextInt();
		
		int result = getGcd(a, b);
		System.out.println(result);
	}
} public class Main {
	
	public static int getGcd(int a, int b) {
		if (a == b)
			return b;
		int bigger = Math.max(a, b);
		int smaller = Math.min(a, b);
		int modded = bigger % smaller;
		if (modded == 0)
			return smaller;
		return getGcd(smaller, bigger % smaller);
	}

	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		int a = s.nextInt();
		int b = s.nextInt();
		
		int result = getGcd(a, b);
		System.out.println(result);
	}
} Main
import java.util.Scanner;
public class Main {
	
	public static int getGcd(int a, int b) {
		if (a == b)
			return b;
		int bigger = Math.max(a, b);
		int smaller = Math.min(a, b);
		int modded = bigger % smaller;
		if (modded == 0)
			return smaller;
		return getGcd(smaller, bigger % smaller);
	}

	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		int a = s.nextInt();
		int b = s.nextInt();
		
		int result = getGcd(a, b);
		System.out.println(result);
	}
}
