s = input().split()

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

if k==1 :
    print(0)
else:
    print(n-k) s = input().split() s input().split() ().split () input split n = int(s[0]) n int(s[0]) int s[0] s 0 k = int(s[1]) k int(s[1]) int s[1] s 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 s = input().split() input().split() s n = int(s[0]) int(s[0]) n k = int(s[1]) int(s[1]) k
s = input().split()

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

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