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();
		while(x != y)
		{
			if(x > y)
			{
				x -= y;
			}
			else
			{
				y -= x;
			}
		}
		System.out.println(x);
		sc.close();
	}
} 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();
		while(x != y)
		{
			if(x > y)
			{
				x -= y;
			}
			else
			{
				y -= x;
			}
		}
		System.out.println(x);
		sc.close();
	}
} Main public static void main(String args[])
	{
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		int y = sc.nextInt();
		while(x != y)
		{
			if(x > y)
			{
				x -= y;
			}
			else
			{
				y -= x;
			}
		}
		System.out.println(x);
		sc.close();
	} main {
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		int y = sc.nextInt();
		while(x != y)
		{
			if(x > y)
			{
				x -= y;
			}
			else
			{
				y -= x;
			}
		}
		System.out.println(x);
		sc.close();
	} 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 while(x != y)
		{
			if(x > y)
			{
				x -= y;
			}
			else
			{
				y -= x;
			}
		} x != y x y {
			if(x > y)
			{
				x -= y;
			}
			else
			{
				y -= x;
			}
		} if(x > y)
			{
				x -= y;
			}
			else
			{
				y -= x;
			} x > y x y {
				x -= y;
			} x -= y x y {
				y -= x;
			} y -= x y x System.out.println(x) System.out.println System.out System System.out x sc.close() sc.close sc String args[] args public class Main
{
	public static void main(String args[])
	{
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		int y = sc.nextInt();
		while(x != y)
		{
			if(x > y)
			{
				x -= y;
			}
			else
			{
				y -= x;
			}
		}
		System.out.println(x);
		sc.close();
	}
} public class Main
{
	public static void main(String args[])
	{
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		int y = sc.nextInt();
		while(x != y)
		{
			if(x > y)
			{
				x -= y;
			}
			else
			{
				y -= x;
			}
		}
		System.out.println(x);
		sc.close();
	}
} 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();
		while(x != y)
		{
			if(x > y)
			{
				x -= y;
			}
			else
			{
				y -= x;
			}
		}
		System.out.println(x);
		sc.close();
	}
}
