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



if K == 1:

    print((0))

else:

    print((N - K))

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

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

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

N, K = list(map(int, input().split()))
print((0 if K == 1 else N - K))

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