import java.util.*;
import java.lang.Math.*;

public class Main{
	private static final Scanner scan = new Scanner(System.in);

	public static void main(String[] args){
		
		int x = scan.nextInt();
		int y = scan.nextInt();
		int gcd;
		gcd = gcd(x, y);
		System.out.println(gcd);
	}

	public static int gcd(int x, int  y){
		int r;
		if(x < y){
			int tmp = x;
			x = y;
			y = tmp;
		}
		while(y > 0){
			r = x % y;
			x = y;
			y = r;
		}
		return x;
	}

	public static int gcdB(int x, int y){
		int n = Math.min(x, y);
		for(int d = n; d > 0; d--){
			if((x % d == 0) && (y % d == 0)){
				return d;
			}
		}
	return -1;
	}
} import java.util.*; util.* java import java.lang.Math.*; Math.* java.lang public class Main{
	private static final Scanner scan = new Scanner(System.in);

	public static void main(String[] args){
		
		int x = scan.nextInt();
		int y = scan.nextInt();
		int gcd;
		gcd = gcd(x, y);
		System.out.println(gcd);
	}

	public static int gcd(int x, int  y){
		int r;
		if(x < y){
			int tmp = x;
			x = y;
			y = tmp;
		}
		while(y > 0){
			r = x % y;
			x = y;
			y = r;
		}
		return x;
	}

	public static int gcdB(int x, int y){
		int n = Math.min(x, y);
		for(int d = n; d > 0; d--){
			if((x % d == 0) && (y % d == 0)){
				return d;
			}
		}
	return -1;
	}
} Main private static final Scanner scan = new Scanner(System.in); scan new Scanner(System.in) public static void main(String[] args){
		
		int x = scan.nextInt();
		int y = scan.nextInt();
		int gcd;
		gcd = gcd(x, y);
		System.out.println(gcd);
	} main {
		
		int x = scan.nextInt();
		int y = scan.nextInt();
		int gcd;
		gcd = gcd(x, y);
		System.out.println(gcd);
	} int x = scan.nextInt(); x scan.nextInt() scan.nextInt scan int y = scan.nextInt(); y scan.nextInt() scan.nextInt scan int gcd; gcd gcd = gcd(x, y) gcd gcd(x, y) gcd x y System.out.println(gcd) System.out.println System.out System System.out gcd String[] args args public static int gcd(int x, int  y){
		int r;
		if(x < y){
			int tmp = x;
			x = y;
			y = tmp;
		}
		while(y > 0){
			r = x % y;
			x = y;
			y = r;
		}
		return x;
	} gcd {
		int r;
		if(x < y){
			int tmp = x;
			x = y;
			y = tmp;
		}
		while(y > 0){
			r = x % y;
			x = y;
			y = r;
		}
		return x;
	} int r; r 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){
			r = x % y;
			x = y;
			y = r;
		} y > 0 y 0 {
			r = x % y;
			x = y;
			y = r;
		} 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 int gcdB(int x, int y){
		int n = Math.min(x, y);
		for(int d = n; d > 0; d--){
			if((x % d == 0) && (y % d == 0)){
				return d;
			}
		}
	return -1;
	} gcdB {
		int n = Math.min(x, y);
		for(int d = n; d > 0; d--){
			if((x % d == 0) && (y % d == 0)){
				return d;
			}
		}
	return -1;
	} int n = Math.min(x, y); n Math.min(x, y) Math.min Math x y for(int d = n; d > 0; d--){
			if((x % d == 0) && (y % d == 0)){
				return d;
			}
		} int d = n; int d = n; d n d > 0 d 0 d-- d-- d {
			if((x % d == 0) && (y % d == 0)){
				return d;
			}
		} {
			if((x % d == 0) && (y % d == 0)){
				return d;
			}
		} if((x % d == 0) && (y % d == 0)){
				return d;
			} (x % d == 0) && (y % d == 0) (x % d == 0) x % d x d 0 (y % d == 0) y % d y d 0 {
				return d;
			} return d; d return -1; -1 1 int x x int y y public class Main{
	private static final Scanner scan = new Scanner(System.in);

	public static void main(String[] args){
		
		int x = scan.nextInt();
		int y = scan.nextInt();
		int gcd;
		gcd = gcd(x, y);
		System.out.println(gcd);
	}

	public static int gcd(int x, int  y){
		int r;
		if(x < y){
			int tmp = x;
			x = y;
			y = tmp;
		}
		while(y > 0){
			r = x % y;
			x = y;
			y = r;
		}
		return x;
	}

	public static int gcdB(int x, int y){
		int n = Math.min(x, y);
		for(int d = n; d > 0; d--){
			if((x % d == 0) && (y % d == 0)){
				return d;
			}
		}
	return -1;
	}
} public class Main{
	private static final Scanner scan = new Scanner(System.in);

	public static void main(String[] args){
		
		int x = scan.nextInt();
		int y = scan.nextInt();
		int gcd;
		gcd = gcd(x, y);
		System.out.println(gcd);
	}

	public static int gcd(int x, int  y){
		int r;
		if(x < y){
			int tmp = x;
			x = y;
			y = tmp;
		}
		while(y > 0){
			r = x % y;
			x = y;
			y = r;
		}
		return x;
	}

	public static int gcdB(int x, int y){
		int n = Math.min(x, y);
		for(int d = n; d > 0; d--){
			if((x % d == 0) && (y % d == 0)){
				return d;
			}
		}
	return -1;
	}
} Main
import java.util.*;
import java.lang.Math.*;

public class Main{
	private static final Scanner scan = new Scanner(System.in);

	public static void main(String[] args){
		
		int x = scan.nextInt();
		int y = scan.nextInt();
		int gcd;
		gcd = gcd(x, y);
		System.out.println(gcd);
	}

	public static int gcd(int x, int  y){
		int r;
		if(x < y){
			int tmp = x;
			x = y;
			y = tmp;
		}
		while(y > 0){
			r = x % y;
			x = y;
			y = r;
		}
		return x;
	}

	public static int gcdB(int x, int y){
		int n = Math.min(x, y);
		for(int d = n; d > 0; d--){
			if((x % d == 0) && (y % d == 0)){
				return d;
			}
		}
	return -1;
	}
}