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


if __name__ == '__main__':
    x, y = [int(i) for i in input().split(" ")]
    print(gdc(x, y)) def gdc(x, y):
    if x % y == 0:
        return y
    else:
        return gdc(y, x%y) gdc if x % y == 0:
        return y
    else:
        return gdc(y, x%y) x % y == 0 x % y x y 0 return y y return gdc(y, x%y) gdc(y, x%y) gdc y x%y x y x x y y if __name__ == '__main__':
    x, y = [int(i) for i in input().split(" ")]
    print(gdc(x, y)) __name__ == '__main__' __name__ '__main__' int(i) for i in input().split(" ") for i in input().split(" ") i input().split(" ") ().split () input split " " for i in input().split(" ") int(i) int i x, y = [int(i) for i in input().split(" ")] x [int(i) for i in input().split(" ")] y print(gdc(x, y)) print gdc(x, y) gdc x y def gdc(x, y):
    if x % y == 0:
        return y
    else:
        return gdc(y, x%y) def gdc(x, y):
    if x % y == 0:
        return y
    else:
        return gdc(y, x%y) gdc y = [int(i) for i in input().split(" ")] [int(i) for i in input().split(" ")] y x, y = [int(i) for i in input().split(" ")] [int(i) for i in input().split(" ")] x
def gdc(x, y):
    if x % y == 0:
        return y
    else:
        return gdc(y, x%y)


if __name__ == '__main__':
    x, y = [int(i) for i in input().split(" ")]
    print(gdc(x, y))