def solve(n, k):
    return n - k if k > 1 else 0

n, k = map(int, input().split())
print(solve(n, k)) def solve(n, k):
    return n - k if k > 1 else 0 solve return n - k if k > 1 else 0 n - k if k > 1 else 0 k > 1 k 1 n - k n k 0 n n k k n, k = map(int, input().split()) n map(int, input().split()) map int input().split() ().split () input split k print(solve(n, k)) print solve(n, k) solve n k k = map(int, input().split()) map(int, input().split()) k def solve(n, k):
    return n - k if k > 1 else 0 def solve(n, k):
    return n - k if k > 1 else 0 solve n, k = map(int, input().split()) map(int, input().split()) n
def solve(n, k):
    return n - k if k > 1 else 0

n, k = map(int, input().split())
print(solve(n, k))