def common(a,b): if a%b==0 : return b return common(b,a%b) a,b = list(map(int,input().split())) if a<b: a,b =b,a print( common(a,b))