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

"""
input:
147 105

output:
21
"""

import sys


def gcd(a, b):
    while b:
        a, b = b, a % b
    return a


if __name__ == '__main__':
    _input = sys.stdin.readlines()
    n1, n2 = map(int, _input[0].split())
    print(gcd(n1, n2)) """
input:
147 105

output:
21
""" import sys sys def gcd(a, b):
    while b:
        a, b = b, a % b
    return a gcd while b:
        a, b = b, a % b
     b a, b = b, a % b a b b a % b a b return a a a a b b if __name__ == '__main__':
    _input = sys.stdin.readlines()
    n1, n2 = map(int, _input[0].split())
    print(gcd(n1, n2)) __name__ == '__main__' __name__ '__main__' _input = sys.stdin.readlines() _input sys.stdin.readlines() sys.stdin.readlines sys.stdin sys stdin readlines n1, n2 = map(int, _input[0].split()) n1 map(int, _input[0].split()) map int _input[0].split() [0].split [0] _input 0 split n2 print(gcd(n1, n2)) print gcd(n1, n2) gcd n1 n2 n1, n2 = map(int, _input[0].split()) map(int, _input[0].split()) n1 def gcd(a, b):
    while b:
        a, b = b, a % b
    return a def gcd(a, b):
    while b:
        a, b = b, a % b
    return a gcd _input = sys.stdin.readlines() sys.stdin.readlines() _input n2 = map(int, _input[0].split()) map(int, _input[0].split()) n2
#!/usr/bin/env python
# -*- coding: utf-8 -*-

"""
input:
147 105

output:
21
"""

import sys


def gcd(a, b):
    while b:
        a, b = b, a % b
    return a


if __name__ == '__main__':
    _input = sys.stdin.readlines()
    n1, n2 = map(int, _input[0].split())
    print(gcd(n1, n2))