import sys readline=sys.stdin.readline from math import gcd as GCD N,M=map(int,readline().split()) ans=GCD(N,M) print(ans)