a,b=map(int,input().split()) s=[] for x in range(1,a+1): if a%x==0 and b%x==0: s.append(x) print(s[-1])