n, k = map(int, input().split())
ans = 1 if n == 1 else n if k == n - 1 else n - 1
print(ans)