# 実験するとわかる、実験は三重ループだった # K==N-1のときはans = N # else ans = N-1 N, K = map(int, input().split()) if K == N-1: ans = N else: ans = N-1 print(ans)