def LI():
    return list(map(int, input().split()))


N, K = LI()

if K == 1:
    ans = 0
else:
    ans = N-K
print(ans) def LI():
    return list(map(int, input().split())) LI return list(map(int, input().split())) list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split N, K = LI() N LI() LI K if K == 1:
    ans = 0
else:
    ans = N-K K == 1 K 1 ans = 0 ans 0 ans = N-K ans N-K N K print(ans) print ans ans = N-K N-K ans def LI():
    return list(map(int, input().split())) def LI():
    return list(map(int, input().split())) LI K = LI() LI() K ans = 0 0 ans N, K = LI() LI() N
def LI():
    return list(map(int, input().split()))


N, K = LI()

if K == 1:
    ans = 0
else:
    ans = N-K
print(ans)
