/* A program to perform Euclid's
    Algorithm to compute gcd */

int gcd(int u, int v)
{
    if(v == 0) return u;
    else return gcd(v, u- u/v * v);
    /* hello u-u/v*v == u mod v */
}

void main()
{
    int x; int y;
    x = input(); y = input();
    print(gcd(x, y));
}