import java.util.Scanner;
class Main
{
    public static void main(String args[])
    {
	Scanner scan=new Scanner(System.in);
	int a,b,temp;
	a=scan.nextInt();
	b=scan.nextInt();
	if(b>a)
	    {
		temp=a;
		a=b;
		b=temp;
	    }
	while(a%b!=0)
	    {
		int tmp=b;
		b=a%b;
		a=tmp;
		
		
	    }
	System.out.println(b);
    }
} import java.util.Scanner; Scanner java.util class Main
{
    public static void main(String args[])
    {
	Scanner scan=new Scanner(System.in);
	int a,b,temp;
	a=scan.nextInt();
	b=scan.nextInt();
	if(b>a)
	    {
		temp=a;
		a=b;
		b=temp;
	    }
	while(a%b!=0)
	    {
		int tmp=b;
		b=a%b;
		a=tmp;
		
		
	    }
	System.out.println(b);
    }
} Main public static void main(String args[])
    {
	Scanner scan=new Scanner(System.in);
	int a,b,temp;
	a=scan.nextInt();
	b=scan.nextInt();
	if(b>a)
	    {
		temp=a;
		a=b;
		b=temp;
	    }
	while(a%b!=0)
	    {
		int tmp=b;
		b=a%b;
		a=tmp;
		
		
	    }
	System.out.println(b);
    } main {
	Scanner scan=new Scanner(System.in);
	int a,b,temp;
	a=scan.nextInt();
	b=scan.nextInt();
	if(b>a)
	    {
		temp=a;
		a=b;
		b=temp;
	    }
	while(a%b!=0)
	    {
		int tmp=b;
		b=a%b;
		a=tmp;
		
		
	    }
	System.out.println(b);
    } Scanner scan=new Scanner(System.in); scan new Scanner(System.in) int a a b b temp; temp a=scan.nextInt() a scan.nextInt() scan.nextInt scan b=scan.nextInt() b scan.nextInt() scan.nextInt scan if(b>a)
	    {
		temp=a;
		a=b;
		b=temp;
	    } b>a b a {
		temp=a;
		a=b;
		b=temp;
	    } temp=a temp a a=b a b b=temp b temp while(a%b!=0)
	    {
		int tmp=b;
		b=a%b;
		a=tmp;
		
		
	    } a%b!=0 a%b a b 0 {
		int tmp=b;
		b=a%b;
		a=tmp;
		
		
	    } int tmp=b; tmp b b=a%b b a%b a b a=tmp a tmp System.out.println(b) System.out.println System.out System System.out b String args[] args
import java.util.Scanner;
class Main
{
    public static void main(String args[])
    {
	Scanner scan=new Scanner(System.in);
	int a,b,temp;
	a=scan.nextInt();
	b=scan.nextInt();
	if(b>a)
	    {
		temp=a;
		a=b;
		b=temp;
	    }
	while(a%b!=0)
	    {
		int tmp=b;
		b=a%b;
		a=tmp;
		
		
	    }
	System.out.println(b);
    }
}