import java.util.Scanner;


public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int x=sc.nextInt();
		int y=sc.nextInt();
		System.out.println(gcd(x,y));

	}

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

	} import java.util.Scanner; Scanner java.util public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int x=sc.nextInt();
		int y=sc.nextInt();
		System.out.println(gcd(x,y));

	}

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

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

	} main {
		Scanner sc = new Scanner(System.in);
		int x=sc.nextInt();
		int y=sc.nextInt();
		System.out.println(gcd(x,y));

	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int x=sc.nextInt(); x sc.nextInt() sc.nextInt sc int y=sc.nextInt(); y sc.nextInt() sc.nextInt sc System.out.println(gcd(x,y)) System.out.println System.out System System.out gcd(x,y) gcd x y String[] args args public static int gcd(int x,int y){
		int r=0;
		if(x<y){
			swap(x,y);
		}
		while(y>0){
			r=x%y;
			x=y;
			y=r;
		}
		return x;
	} gcd {
		int r=0;
		if(x<y){
			swap(x,y);
		}
		while(y>0){
			r=x%y;
			x=y;
			y=r;
		}
		return x;
	} int r=0; r 0 if(x<y){
			swap(x,y);
		} x<y x y {
			swap(x,y);
		} swap(x,y) swap x y 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 void swap(int x,int y){
		int dummy=y;
		y=x;
		x=dummy;
	} swap {
		int dummy=y;
		y=x;
		x=dummy;
	} int dummy=y; dummy y y=x y x x=dummy x dummy int x x int y y public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int x=sc.nextInt();
		int y=sc.nextInt();
		System.out.println(gcd(x,y));

	}

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

	} public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int x=sc.nextInt();
		int y=sc.nextInt();
		System.out.println(gcd(x,y));

	}

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

	} Main
import java.util.Scanner;


public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int x=sc.nextInt();
		int y=sc.nextInt();
		System.out.println(gcd(x,y));

	}

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

	}
