import sys

def solve():
    a, b = map(int, input().split())
    ans = gcd(a, b)
    print(ans)

def gcd(a, b):
    return gcd(b, a % b) if b else a

if __name__ == '__main__':
    solve() import sys sys def solve():
    a, b = map(int, input().split())
    ans = gcd(a, b)
    print(ans) solve a, b = map(int, input().split()) a map(int, input().split()) map int input().split() ().split () input split b ans = gcd(a, b) ans gcd(a, b) gcd a b print(ans) print ans def gcd(a, b):
    return gcd(b, a % b) if b else a gcd return gcd(b, a % b) if b else a gcd(b, a % b) if b else a b gcd(b, a % b) gcd b a % b a b a a a b b if __name__ == '__main__':
    solve() __name__ == '__main__' __name__ '__main__' solve() solve def gcd(a, b):
    return gcd(b, a % b) if b else a def gcd(a, b):
    return gcd(b, a % b) if b else a gcd def solve():
    a, b = map(int, input().split())
    ans = gcd(a, b)
    print(ans) def solve():
    a, b = map(int, input().split())
    ans = gcd(a, b)
    print(ans) solve
import sys

def solve():
    a, b = map(int, input().split())
    ans = gcd(a, b)
    print(ans)

def gcd(a, b):
    return gcd(b, a % b) if b else a

if __name__ == '__main__':
    solve()