# -*- coding: utf-8 -*-


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


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


if __name__ == '__main__':
    main() def converter(a, b):
    if a == 0:
        return b
    else:
        return converter(b % a, a) converter if a == 0:
        return b
    else:
        return converter(b % a, a) a == 0 a 0 return b b return converter(b % a, a) converter(b % a, a) converter b % a b a a a a b b def main():
    a, b = sorted([int(x) for x in raw_input().strip().split(' ')])
    print converter(a, b)  main 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 if __name__ == '__main__':
    main() __name__ == '__main__' __name__ '__main__' main() main def converter(a, b):
    if a == 0:
        return b
    else:
        return converter(b % a, a) def converter(a, b):
    if a == 0:
        return b
    else:
        return converter(b % a, a) converter def main():
    a, b = sorted([int(x) for x in raw_input().strip().split(' ')])
    print converter(a, b)  def main():
    a, b = sorted([int(x) for x in raw_input().strip().split(' ')])
    print converter(a, b)  main
# -*- coding: utf-8 -*-


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


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


if __name__ == '__main__':
    main()