N,K = map(int,input().split()) if N == 1: print(1) elif K != N - 1: print(N - 1) else: print(N)