n, k = list(map(int, input().split()))

if k == 1:

  print((0))

else:

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

if k != 1:

    print((n-k))

else:

    print((0))

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

n, k = list(map(int, input().split()))
if k != 1:
    print((n - k))
else:
    print((0))

-if k == 1: +if k != 1: +    print((n - k)) +else: -else: -    print((n - k))