def gcd(x, y):
    if x > y:
        return gcd(y, x)
    if y % x == 0:
        return x
    else:
        return gcd(y % x, x)


def main():
    x, y = map(int, input().split())
    print(gcd(x,y))

if __name__ == "__main__":
    main() def gcd(x, y):
    if x > y:
        return gcd(y, x)
    if y % x == 0:
        return x
    else:
        return gcd(y % x, x) gcd if x > y:
        return gcd(y, x)
     x > y x y return gcd(y, x) gcd(y, x) gcd y x if y % x == 0:
        return x
    else:
        return gcd(y % x, x) y % x == 0 y % x y x 0 return x x return gcd(y % x, x) gcd(y % x, x) gcd y % x y x x x x y y def main():
    x, y = map(int, input().split())
    print(gcd(x,y)) main x, y = map(int, input().split()) x map(int, input().split()) map int input().split() ().split () input split y print(gcd(x,y)) print gcd(x,y) gcd x y if __name__ == "__main__":
    main() __name__ == "__main__" __name__ "__main__" main() main def main():
    x, y = map(int, input().split())
    print(gcd(x,y)) def main():
    x, y = map(int, input().split())
    print(gcd(x,y)) main def gcd(x, y):
    if x > y:
        return gcd(y, x)
    if y % x == 0:
        return x
    else:
        return gcd(y % x, x) def gcd(x, y):
    if x > y:
        return gcd(y, x)
    if y % x == 0:
        return x
    else:
        return gcd(y % x, x) gcd
def gcd(x, y):
    if x > y:
        return gcd(y, x)
    if y % x == 0:
        return x
    else:
        return gcd(y % x, x)


def main():
    x, y = map(int, input().split())
    print(gcd(x,y))

if __name__ == "__main__":
    main()