from sys import stdin
l = stdin.readline().rstrip().split()

n = int(l[0])
k=int(l[1])

if k == 1:
    print(0)
else:
    print(n-k) from sys import stdin l = stdin.readline().rstrip().split() l stdin.readline().rstrip().split() stdin.readline().rstrip().split stdin.readline().rstrip() stdin.readline().rstrip stdin.readline() stdin.readline stdin readline rstrip split n = int(l[0]) n int(l[0]) int l[0] l 0 k=int(l[1]) k int(l[1]) int l[1] l 1 if k == 1:
    print(0)
else:
    print(n-k) k == 1 k 1 print(0) print 0 print(n-k) print n-k n k k=int(l[1]) int(l[1]) k n = int(l[0]) int(l[0]) n l = stdin.readline().rstrip().split() stdin.readline().rstrip().split() l
from sys import stdin
l = stdin.readline().rstrip().split()

n = int(l[0])
k=int(l[1])

if k == 1:
    print(0)
else:
    print(n-k)