import java.util.*;

public class Main {
	static int gcd(int x, int y) {
		if(x < y) {
			int tmp = x;
			x = y;
			y = tmp;
		}
		while(y > 0) {
			int r = x % y;
			x = y;
			y = r;
		}
		return x;
	}
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		System.out.println(gcd(a, b));
	}
}
 import java.util.*; util.* java public class Main {
	static int gcd(int x, int y) {
		if(x < y) {
			int tmp = x;
			x = y;
			y = tmp;
		}
		while(y > 0) {
			int r = x % y;
			x = y;
			y = r;
		}
		return x;
	}
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		System.out.println(gcd(a, b));
	}
} Main static int gcd(int x, int y) {
		if(x < y) {
			int tmp = x;
			x = y;
			y = tmp;
		}
		while(y > 0) {
			int r = x % y;
			x = y;
			y = r;
		}
		return x;
	} gcd {
		if(x < y) {
			int tmp = x;
			x = y;
			y = tmp;
		}
		while(y > 0) {
			int r = x % y;
			x = y;
			y = r;
		}
		return x;
	} if(x < y) {
			int tmp = x;
			x = y;
			y = tmp;
		} x < y x y {
			int tmp = x;
			x = y;
			y = tmp;
		} int tmp = x; tmp x x = y x y y = tmp y tmp while(y > 0) {
			int r = x % y;
			x = y;
			y = r;
		} y > 0 y 0 {
			int r = x % y;
			x = y;
			y = r;
		} int r = x % y; r x % y x y x = y x y y = r y r return x; x int x x int y y public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		System.out.println(gcd(a, b));
	} main {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		System.out.println(gcd(a, b));
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int a = sc.nextInt(); a sc.nextInt() sc.nextInt sc int b = sc.nextInt(); b sc.nextInt() sc.nextInt sc System.out.println(gcd(a, b)) System.out.println System.out System System.out gcd(a, b) gcd a b String[] args args public class Main {
	static int gcd(int x, int y) {
		if(x < y) {
			int tmp = x;
			x = y;
			y = tmp;
		}
		while(y > 0) {
			int r = x % y;
			x = y;
			y = r;
		}
		return x;
	}
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		System.out.println(gcd(a, b));
	}
} public class Main {
	static int gcd(int x, int y) {
		if(x < y) {
			int tmp = x;
			x = y;
			y = tmp;
		}
		while(y > 0) {
			int r = x % y;
			x = y;
			y = r;
		}
		return x;
	}
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		System.out.println(gcd(a, b));
	}
} Main
import java.util.*;

public class Main {
	static int gcd(int x, int y) {
		if(x < y) {
			int tmp = x;
			x = y;
			y = tmp;
		}
		while(y > 0) {
			int r = x % y;
			x = y;
			y = r;
		}
		return x;
	}
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		System.out.println(gcd(a, b));
	}
}

