import std.stdio;
import std.conv;
import std.algorithm;
import std.range;
import std.string;
import std.typecons;
import std.math;
import std.range;
auto gcd(T)(T x, T y)
{
    if (x < y)
        x.swap(y);
    while (y > 0)
    {
        auto r = x % y;
        x = y;
        y = r;
    }
    return x;
}
void main()
{
    auto a = readln().strip.split(" ").map!(to!int);
    auto x = a[0];
    auto y = a[1];
    writeln(gcd(x, y));
}
