def eucli(a, b):
    r = a % b
    if r != 0:
        return eucli(b, r)
    else:
        return b

if __name__=="__main__":
    x, y = map(int, input().split())
    print(eucli(x, y)) def eucli(a, b):
    r = a % b
    if r != 0:
        return eucli(b, r)
    else:
        return b eucli r = a % b r a % b a b if r != 0:
        return eucli(b, r)
    else:
        return b r != 0 r 0 return eucli(b, r) eucli(b, r) eucli b r return b b a a b b if __name__=="__main__":
    x, y = map(int, input().split())
    print(eucli(x, y)) __name__=="__main__" __name__ "__main__" x, y = map(int, input().split()) x map(int, input().split()) map int input().split() ().split () input split y print(eucli(x, y)) print eucli(x, y) eucli x y def eucli(a, b):
    r = a % b
    if r != 0:
        return eucli(b, r)
    else:
        return b def eucli(a, b):
    r = a % b
    if r != 0:
        return eucli(b, r)
    else:
        return b eucli x, y = map(int, input().split()) map(int, input().split()) x y = map(int, input().split()) map(int, input().split()) y
def eucli(a, b):
    r = a % b
    if r != 0:
        return eucli(b, r)
    else:
        return b

if __name__=="__main__":
    x, y = map(int, input().split())
    print(eucli(x, y))