line = input().split(" ") N = int(line[0]) K = int(line[1]) if N == 1: print(1) elif not K == N - 1: print(N-1) else: print(N)