m,n = map(int,input().split()) k = min(m,n) for i in range(k,0,-1): if m%i == 0 and n%i == 0: gcd = i break print(gcd)