n,k=map(int,input().split()) g=lambda a,b:a if b==0 else g(b,a%b) print(max(map(lambda i:g(i,n-i),range(1,n))))