#4.2.1 a = int(input()) b = int(input()) if a>b: a,b=b,a for i in range(a,0,-1): if a%i==0 and b%i==0: print(i) while b!=0: a,b=b,a%b print(a)