using System;
using System.Collections.Generic;


class Program
{
    static void Main(string[] args)
    {
        Input CInput = new Input();

        int[] input = new int[(int)Input.Define.MAX_ArraySize];

        input = CInput.Line1_int(' ', 2);

        System.Console.WriteLine(Gcd(input[0], input[1]));

    }

    static int Gcd(int a, int b)
    {
        if (a < b) return Gcd(b, a);
        int d = 0;
        do
        {
            d = a%b;
            a = b;
            b = d;
        } while (d != 0);
        return a;
    }
}






class Input
{
    public enum Define
    {
        MAX_ArraySize = 100,
        ArraySize2d = 100,                // 2?¬?????????????[][?] ???????
    }

    public string Line1_string()
    {
        return Console.ReadLine();
    }

    public string[] Line1_string(int chr)
    {
        var input = Console.ReadLine();
        var split = input.Split(' ');
        return split;
    }

    public int Line1_int()
    {
        var input = Console.ReadLine();
        return int.Parse(input);
    }

    public double Line1_double()
    {
        var input = Console.ReadLine();
        return double.Parse(input);
    }

    public int[] Line1_int(int chr, int num)
    {
        var input = Console.ReadLine();
        var split = input.Split(' ');
        int[] spliti = new int[100];
        for (int i = 0; i < num; i++)
        {
            spliti[i] = int.Parse(split[i]);
        }
        return spliti;
    }

    public int[] Multiline_int(ref int datanum)
    {
        int i = 0;
        int[] data = new int[(int)Input.Define.MAX_ArraySize];
        while (true)
        {
            var input = Console.ReadLine();
            var value = int.Parse(input);
            if (value == 0) break;
            data[i] = value;
            i++;
        }
        datanum = i;
        return data;
    }

    /// <summary>
    /// ?????°??????int??????????????????????????????
    /// </summary>
    /// <param name="chr">???????????????</param>
    /// <param name="num">?????????????????????????????°</param>
    /// <param name="datanum">??????????????????????????°</param>
    /// <returns></returns>
    public int[,] Multiline_int(int chr, int num, ref int datanum)
    {
        int i = 0, zerocount = 0;
        int[,] data = new int[(int)Input.Define.MAX_ArraySize, (int)Input.Define.ArraySize2d];
        while (true)
        {
            var input = Console.ReadLine();
            var split = input.Split(' ');
            int[] spliti = new int[100];
            zerocount = 0;
            for (int j = 0; j < num; j++)
            {
                spliti[j] = int.Parse(split[j]);
                if (spliti[j] == 0) zerocount++;
            }
            if (zerocount == num) break;
            for (int j = 0; j < num; j++)
            {
                if (spliti[0] == 0 && spliti[1] == 0) break; // ???????????????????????????
            }
            for (int j = 0; j < num; j++)
            {
                data[i, j] = spliti[j];
            }
            i++;
        }
        datanum = i;
        return data;
    }

    /// <summary>
    /// ?????°??????int??????????????????????????????
    /// </summary>
    /// <param name="chr">???????????????</param>
    /// <param name="num">?????????????????????????????°</param>
    /// <param name="loadnum">???????????????????????°</param>
    /// <returns></returns>
    public int[,] Multiline_int(int chr, int num, int loadnum)
    {
        int i = 0;
        int[,] data = new int[(int)Input.Define.MAX_ArraySize, (int)Input.Define.ArraySize2d];
        while (true)
        {
            if (loadnum == i) break;

            var input = Console.ReadLine();
            var split = input.Split(' ');
            int[] spliti = new int[100];
            for (int j = 0; j < num; j++)
            {
                spliti[j] = int.Parse(split[j]);
            }
            for (int j = 0; j < num; j++)
            {
                data[i, j] = spliti[j];
            }
            i++;
        }
        return data;
    }


}

//??£?¨????????????¬

//int[] input = new int[(int)Input.Define.MAX_ArraySize];
//int[,] input = new int[(int)Input.Define.MAX_ArraySize, (int)Input.Define.ArraySize2d];

class EasyTask
{
    public void Swap(ref int a, ref int b)
    {
        int buf = 0;
        buf = a;
        a = b;
        b = buf;
    }






}

Measured memory_bytes: 9232