#!/usr/bin/env python
# -*- coding: utf-8 -*-


def mygcd(x, y):
    if x == 0 or y == 0:
        return max(x, y)
    else:
        (x1, y1) = (max(x, y), min(x, y))
        return mygcd(y, x % y)


def main():
    print(mygcd(*map(int, input().split())))

if __name__ == "__main__":
    main() def mygcd(x, y):
    if x == 0 or y == 0:
        return max(x, y)
    else:
        (x1, y1) = (max(x, y), min(x, y))
        return mygcd(y, x % y) mygcd if x == 0 or y == 0:
        return max(x, y)
    else:
        (x1, y1) = (max(x, y), min(x, y))
        return mygcd(y, x % y) x == 0 or y == 0 x == 0 x 0 y == 0 y 0 return max(x, y) max(x, y) max x y (x1, y1) = (max(x, y), min(x, y)) (x1, y1) x1 y1 (max(x, y), min(x, y)) max(x, y) max x y min(x, y) min x y return mygcd(y, x % y) mygcd(y, x % y) mygcd y x % y x y x x y y def main():
    print(mygcd(*map(int, input().split()))) main print(mygcd(*map(int, input().split()))) print mygcd(*map(int, input().split())) mygcd *map(int, input().split()) map(int, input().split()) map int input().split() ().split () input split if __name__ == "__main__":
    main() __name__ == "__main__" __name__ "__main__" main() main def mygcd(x, y):
    if x == 0 or y == 0:
        return max(x, y)
    else:
        (x1, y1) = (max(x, y), min(x, y))
        return mygcd(y, x % y) def mygcd(x, y):
    if x == 0 or y == 0:
        return max(x, y)
    else:
        (x1, y1) = (max(x, y), min(x, y))
        return mygcd(y, x % y) mygcd def main():
    print(mygcd(*map(int, input().split()))) def main():
    print(mygcd(*map(int, input().split()))) main
#!/usr/bin/env python
# -*- coding: utf-8 -*-


def mygcd(x, y):
    if x == 0 or y == 0:
        return max(x, y)
    else:
        (x1, y1) = (max(x, y), min(x, y))
        return mygcd(y, x % y)


def main():
    print(mygcd(*map(int, input().split())))

if __name__ == "__main__":
    main()