N, K = list(map(int, input().split()))

if K == 1:
    ans = 0
else:
    min_ = 1
    max_ = N - (K - 1)  # K-1人に一つずつ配った残り
    ans = max_ - min_

print(ans) N, K = list(map(int, input().split())) N list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split K if K == 1:
    ans = 0
else:
    min_ = 1
    max_ = N - (K - 1)  # K-1人に一つずつ配った残り
    ans = max_ - min_ K == 1 K 1 ans = 0 ans 0 min_ = 1 min_ 1 max_ = N - (K - 1) max_ N - (K - 1) N K - 1 K 1 ans = max_ - min_ ans max_ - min_ max_ min_ print(ans) print ans N, K = list(map(int, input().split())) list(map(int, input().split())) N K = list(map(int, input().split())) list(map(int, input().split())) K max_ = N - (K - 1) N - (K - 1) max_ ans = max_ - min_ max_ - min_ ans min_ = 1 1 min_ ans = 0 0 ans
N, K = list(map(int, input().split()))

if K == 1:
    ans = 0
else:
    min_ = 1
    max_ = N - (K - 1)  # K-1人に一つずつ配った残り
    ans = max_ - min_

print(ans)