import java.util.Scanner;
	class Uc{
		int r,x,y;
		Uc(int X,int Y){
			x=X;y=Y;
		}
		void swap(){
			r=x;x=y;y=r;
		}
		void gcd(){
			r=x;
			x=y;
			y=r%y;
		}
	}
public class Main{
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		Uc u=new Uc(sc.nextInt(),sc.nextInt());;
		if(u.x<u.y) {
			u.swap();
		}
		while(u.y>0) {
			u.gcd();
		}
		System.out.println(u.x);
		sc.close();
	}
}
 import java.util.Scanner; Scanner java.util class Uc{
		int r,x,y;
		Uc(int X,int Y){
			x=X;y=Y;
		}
		void swap(){
			r=x;x=y;y=r;
		}
		void gcd(){
			r=x;
			x=y;
			y=r%y;
		}
	} Uc int r r x x y; y Uc(int X,int Y){
			x=X;y=Y;
		} Uc {
			x=X;y=Y;
		} x=X x X y=Y y Y int X X int Y Y void swap(){
			r=x;x=y;y=r;
		} swap {
			r=x;x=y;y=r;
		} r=x r x x=y x y y=r y r void gcd(){
			r=x;
			x=y;
			y=r%y;
		} gcd {
			r=x;
			x=y;
			y=r%y;
		} r=x r x x=y x y y=r%y y r%y r y public class Main{
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		Uc u=new Uc(sc.nextInt(),sc.nextInt());;
		if(u.x<u.y) {
			u.swap();
		}
		while(u.y>0) {
			u.gcd();
		}
		System.out.println(u.x);
		sc.close();
	}
} Main public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		Uc u=new Uc(sc.nextInt(),sc.nextInt());;
		if(u.x<u.y) {
			u.swap();
		}
		while(u.y>0) {
			u.gcd();
		}
		System.out.println(u.x);
		sc.close();
	} main {
		Scanner sc=new Scanner(System.in);
		Uc u=new Uc(sc.nextInt(),sc.nextInt());;
		if(u.x<u.y) {
			u.swap();
		}
		while(u.y>0) {
			u.gcd();
		}
		System.out.println(u.x);
		sc.close();
	} Scanner sc=new Scanner(System.in); sc new Scanner(System.in) Uc u=new Uc(sc.nextInt(),sc.nextInt()); u new Uc(sc.nextInt(),sc.nextInt()) if(u.x<u.y) {
			u.swap();
		} u.x<u.y u.x u u.x u.y u u.y {
			u.swap();
		} u.swap() u.swap u while(u.y>0) {
			u.gcd();
		} u.y>0 u.y u u.y 0 {
			u.gcd();
		} u.gcd() u.gcd u System.out.println(u.x) System.out.println System.out System System.out u.x u u.x sc.close() sc.close sc String[] args args public class Main{
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		Uc u=new Uc(sc.nextInt(),sc.nextInt());;
		if(u.x<u.y) {
			u.swap();
		}
		while(u.y>0) {
			u.gcd();
		}
		System.out.println(u.x);
		sc.close();
	}
} public class Main{
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		Uc u=new Uc(sc.nextInt(),sc.nextInt());;
		if(u.x<u.y) {
			u.swap();
		}
		while(u.y>0) {
			u.gcd();
		}
		System.out.println(u.x);
		sc.close();
	}
} Main
import java.util.Scanner;
	class Uc{
		int r,x,y;
		Uc(int X,int Y){
			x=X;y=Y;
		}
		void swap(){
			r=x;x=y;y=r;
		}
		void gcd(){
			r=x;
			x=y;
			y=r%y;
		}
	}
public class Main{
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		Uc u=new Uc(sc.nextInt(),sc.nextInt());;
		if(u.x<u.y) {
			u.swap();
		}
		while(u.y>0) {
			u.gcd();
		}
		System.out.println(u.x);
		sc.close();
	}
}

