import java.util.Scanner;

public class Main
{
    public static void main(String[] args)
    {
	Scanner In = new Scanner(System.in);

	int a,b;

	do
	    {
		a = In.nextInt();
		b = In.nextInt();
	    }while(1 >= a && a >= Math.pow(10,9) && 1 >= b && b >= Math.pow(10,9));


	gcd(a,b);
	
    }
	private static void gcd(int a, int b)
	{
	    int c;
	    if(a < b)
		swap(a,b);

	    while(b > 0)
		{
		    c = a % b;
		    a = b;
		    b = c;
		}
	System.out.println(a);
	}

    private static void swap(int a, int b)
    {
	int d;
	d = a;
	a = b;
	b = d;
    }
} import java.util.Scanner; Scanner java.util public class Main
{
    public static void main(String[] args)
    {
	Scanner In = new Scanner(System.in);

	int a,b;

	do
	    {
		a = In.nextInt();
		b = In.nextInt();
	    }while(1 >= a && a >= Math.pow(10,9) && 1 >= b && b >= Math.pow(10,9));


	gcd(a,b);
	
    }
	private static void gcd(int a, int b)
	{
	    int c;
	    if(a < b)
		swap(a,b);

	    while(b > 0)
		{
		    c = a % b;
		    a = b;
		    b = c;
		}
	System.out.println(a);
	}

    private static void swap(int a, int b)
    {
	int d;
	d = a;
	a = b;
	b = d;
    }
} Main public static void main(String[] args)
    {
	Scanner In = new Scanner(System.in);

	int a,b;

	do
	    {
		a = In.nextInt();
		b = In.nextInt();
	    }while(1 >= a && a >= Math.pow(10,9) && 1 >= b && b >= Math.pow(10,9));


	gcd(a,b);
	
    } main {
	Scanner In = new Scanner(System.in);

	int a,b;

	do
	    {
		a = In.nextInt();
		b = In.nextInt();
	    }while(1 >= a && a >= Math.pow(10,9) && 1 >= b && b >= Math.pow(10,9));


	gcd(a,b);
	
    } Scanner In = new Scanner(System.in); In new Scanner(System.in) int a a b; b do
	    {
		a = In.nextInt();
		b = In.nextInt();
	    }while(1 >= a && a >= Math.pow(10,9) && 1 >= b && b >= Math.pow(10,9)); 1 >= a && a >= Math.pow(10,9) && 1 >= b && b >= Math.pow(10,9) 1 >= b 1 >= a && a >= Math.pow(10,9) && 1 >= b && b >= Math.pow(10,9) 1 >= a 1 a a >= Math.pow(10,9) a Math.pow(10,9) Math.pow Math 10 9 1 >= b 1 b b >= Math.pow(10,9) b Math.pow(10,9) Math.pow Math 10 9 {
		a = In.nextInt();
		b = In.nextInt();
	    } a = In.nextInt() a In.nextInt() In.nextInt In b = In.nextInt() b In.nextInt() In.nextInt In gcd(a,b) gcd a b String[] args args private static void gcd(int a, int b)
	{
	    int c;
	    if(a < b)
		swap(a,b);

	    while(b > 0)
		{
		    c = a % b;
		    a = b;
		    b = c;
		}
	System.out.println(a);
	} gcd {
	    int c;
	    if(a < b)
		swap(a,b);

	    while(b > 0)
		{
		    c = a % b;
		    a = b;
		    b = c;
		}
	System.out.println(a);
	} int c; c if(a < b)
		swap(a,b); a < b a b swap(a,b) swap a b while(b > 0)
		{
		    c = a % b;
		    a = b;
		    b = c;
		} b > 0 b 0 {
		    c = a % b;
		    a = b;
		    b = c;
		} c = a % b c a % b a b a = b a b b = c b c System.out.println(a) System.out.println System.out System System.out a int a a int b b private static void swap(int a, int b)
    {
	int d;
	d = a;
	a = b;
	b = d;
    } swap {
	int d;
	d = a;
	a = b;
	b = d;
    } int d; d d = a d a a = b a b b = d b d int a a int b b public class Main
{
    public static void main(String[] args)
    {
	Scanner In = new Scanner(System.in);

	int a,b;

	do
	    {
		a = In.nextInt();
		b = In.nextInt();
	    }while(1 >= a && a >= Math.pow(10,9) && 1 >= b && b >= Math.pow(10,9));


	gcd(a,b);
	
    }
	private static void gcd(int a, int b)
	{
	    int c;
	    if(a < b)
		swap(a,b);

	    while(b > 0)
		{
		    c = a % b;
		    a = b;
		    b = c;
		}
	System.out.println(a);
	}

    private static void swap(int a, int b)
    {
	int d;
	d = a;
	a = b;
	b = d;
    }
} public class Main
{
    public static void main(String[] args)
    {
	Scanner In = new Scanner(System.in);

	int a,b;

	do
	    {
		a = In.nextInt();
		b = In.nextInt();
	    }while(1 >= a && a >= Math.pow(10,9) && 1 >= b && b >= Math.pow(10,9));


	gcd(a,b);
	
    }
	private static void gcd(int a, int b)
	{
	    int c;
	    if(a < b)
		swap(a,b);

	    while(b > 0)
		{
		    c = a % b;
		    a = b;
		    b = c;
		}
	System.out.println(a);
	}

    private static void swap(int a, int b)
    {
	int d;
	d = a;
	a = b;
	b = d;
    }
} Main
import java.util.Scanner;

public class Main
{
    public static void main(String[] args)
    {
	Scanner In = new Scanner(System.in);

	int a,b;

	do
	    {
		a = In.nextInt();
		b = In.nextInt();
	    }while(1 >= a && a >= Math.pow(10,9) && 1 >= b && b >= Math.pow(10,9));


	gcd(a,b);
	
    }
	private static void gcd(int a, int b)
	{
	    int c;
	    if(a < b)
		swap(a,b);

	    while(b > 0)
		{
		    c = a % b;
		    a = b;
		    b = c;
		}
	System.out.println(a);
	}

    private static void swap(int a, int b)
    {
	int d;
	d = a;
	a = b;
	b = d;
    }
}