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

"""
input:
147 105

output:
21
"""

import sys


def gcd(x, y):
    if x < y:
        x, y = y, x

    while y > 0:
        r = x % y
        x = y
        y = r

    return x


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(x, y):
    if x < y:
        x, y = y, x

    while y > 0:
        r = x % y
        x = y
        y = r

    return x gcd if x < y:
        x, y = y, x

     x < y x y x, y = y, x x y y x while y > 0:
        r = x % y
        x = y
        y = r

     y > 0 y 0 r = x % y r x % y x y x = y x y y = r y r return x x x x y y 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 def gcd(x, y):
    if x < y:
        x, y = y, x

    while y > 0:
        r = x % y
        x = y
        y = r

    return x def gcd(x, y):
    if x < y:
        x, y = y, x

    while y > 0:
        r = x % y
        x = y
        y = r

    return x gcd _input = sys.stdin.readlines() sys.stdin.readlines() _input n2 = map(int, _input[0].split()) map(int, _input[0].split()) n2 n1, n2 = map(int, _input[0].split()) map(int, _input[0].split()) n1
#!/usr/bin/env python
# -*- coding: utf-8 -*-

"""
input:
147 105

output:
21
"""

import sys


def gcd(x, y):
    if x < y:
        x, y = y, x

    while y > 0:
        r = x % y
        x = y
        y = r

    return x


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