N, K = map(int, input().split()) print(N-1 if K > 1 else N-2)