def god(a,c): while c: a,c=c,a%c return a a,c=input().split() a=int(a) c=int(c) if a<c: a,c=c,a res=god(a,c) print(res)