import java.util.Scanner;

public class Main{


	public static int gcd(int a, int b){

		if(b==0)return a;
		return gcd(b, a%b);
	}

	public static int gcd_roop(int a, int b){

		while(true){
			if(b==0)return a;
			int t;
			t=a;
			a=b;
			b=t%b;
		}

	}



	public static void main(String[] args){

		int a, b;

		Scanner scan=new Scanner(System.in);
		a=scan.nextInt();
		b=scan.nextInt();

		System.out.println(gcd_roop(a, b));
		scan.close();

	}

} import java.util.Scanner; Scanner java.util public class Main{


	public static int gcd(int a, int b){

		if(b==0)return a;
		return gcd(b, a%b);
	}

	public static int gcd_roop(int a, int b){

		while(true){
			if(b==0)return a;
			int t;
			t=a;
			a=b;
			b=t%b;
		}

	}



	public static void main(String[] args){

		int a, b;

		Scanner scan=new Scanner(System.in);
		a=scan.nextInt();
		b=scan.nextInt();

		System.out.println(gcd_roop(a, b));
		scan.close();

	}

} Main public static int gcd(int a, int b){

		if(b==0)return a;
		return gcd(b, a%b);
	} gcd {

		if(b==0)return a;
		return gcd(b, a%b);
	} if(b==0)return a; b==0 b 0 return a; a return gcd(b, a%b); gcd(b, a%b) gcd b a%b a b int a a int b b public static int gcd_roop(int a, int b){

		while(true){
			if(b==0)return a;
			int t;
			t=a;
			a=b;
			b=t%b;
		}

	} gcd_roop {

		while(true){
			if(b==0)return a;
			int t;
			t=a;
			a=b;
			b=t%b;
		}

	} while(true){
			if(b==0)return a;
			int t;
			t=a;
			a=b;
			b=t%b;
		} true {
			if(b==0)return a;
			int t;
			t=a;
			a=b;
			b=t%b;
		} if(b==0)return a; b==0 b 0 return a; a int t; t t=a t a a=b a b b=t%b b t%b t b int a a int b b public static void main(String[] args){

		int a, b;

		Scanner scan=new Scanner(System.in);
		a=scan.nextInt();
		b=scan.nextInt();

		System.out.println(gcd_roop(a, b));
		scan.close();

	} main {

		int a, b;

		Scanner scan=new Scanner(System.in);
		a=scan.nextInt();
		b=scan.nextInt();

		System.out.println(gcd_roop(a, b));
		scan.close();

	} int a a b; b Scanner scan=new Scanner(System.in); scan new Scanner(System.in) a=scan.nextInt() a scan.nextInt() scan.nextInt scan b=scan.nextInt() b scan.nextInt() scan.nextInt scan System.out.println(gcd_roop(a, b)) System.out.println System.out System System.out gcd_roop(a, b) gcd_roop a b scan.close() scan.close scan String[] args args public class Main{


	public static int gcd(int a, int b){

		if(b==0)return a;
		return gcd(b, a%b);
	}

	public static int gcd_roop(int a, int b){

		while(true){
			if(b==0)return a;
			int t;
			t=a;
			a=b;
			b=t%b;
		}

	}



	public static void main(String[] args){

		int a, b;

		Scanner scan=new Scanner(System.in);
		a=scan.nextInt();
		b=scan.nextInt();

		System.out.println(gcd_roop(a, b));
		scan.close();

	}

} public class Main{


	public static int gcd(int a, int b){

		if(b==0)return a;
		return gcd(b, a%b);
	}

	public static int gcd_roop(int a, int b){

		while(true){
			if(b==0)return a;
			int t;
			t=a;
			a=b;
			b=t%b;
		}

	}



	public static void main(String[] args){

		int a, b;

		Scanner scan=new Scanner(System.in);
		a=scan.nextInt();
		b=scan.nextInt();

		System.out.println(gcd_roop(a, b));
		scan.close();

	}

} Main
import java.util.Scanner;

public class Main{


	public static int gcd(int a, int b){

		if(b==0)return a;
		return gcd(b, a%b);
	}

	public static int gcd_roop(int a, int b){

		while(true){
			if(b==0)return a;
			int t;
			t=a;
			a=b;
			b=t%b;
		}

	}



	public static void main(String[] args){

		int a, b;

		Scanner scan=new Scanner(System.in);
		a=scan.nextInt();
		b=scan.nextInt();

		System.out.println(gcd_roop(a, b));
		scan.close();

	}

}