def converter(a, b):
    if b%a == 0:
        return a
    else:
        return converter(b % a, a)


a, b = sorted([int(x) for x in raw_input().strip().split(' ')])
print converter(a, b)  def converter(a, b):
    if b%a == 0:
        return a
    else:
        return converter(b % a, a) converter if b%a == 0:
        return a
    else:
        return converter(b % a, a) b%a == 0 b%a b a 0 return a a return converter(b % a, a) converter(b % a, a) converter b % a b a a a a b b int(x) for x in raw_input().strip().split(' ') for x in raw_input().strip().split(' ') x raw_input().strip().split(' ') ().strip().split ().strip() ().strip () raw_input strip split ' ' for x in raw_input().strip().split(' ') int(x) int x a, b = sorted([int(x) for x in raw_input().strip().split(' ')]) a sorted([int(x) for x in raw_input().strip().split(' ')]) sorted [int(x) for x in raw_input().strip().split(' ')] b print converter(a, b) converter a b def converter(a, b):
    if b%a == 0:
        return a
    else:
        return converter(b % a, a) def converter(a, b):
    if b%a == 0:
        return a
    else:
        return converter(b % a, a) converter b = sorted([int(x) for x in raw_input().strip().split(' ')]) sorted([int(x) for x in raw_input().strip().split(' ')]) b a, b = sorted([int(x) for x in raw_input().strip().split(' ')]) sorted([int(x) for x in raw_input().strip().split(' ')]) a
def converter(a, b):
    if b%a == 0:
        return a
    else:
        return converter(b % a, a)


a, b = sorted([int(x) for x in raw_input().strip().split(' ')])
print converter(a, b) 