import sys

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

if k==1 :
    print(0)
else :
    print(n-k) import sys sys n,k = input().split() n input().split() ().split () input split k n,k = int(n), int(k) n int(n) int n k int(k) int k 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 = input().split() input().split() k n,k = int(n), int(k) int(n) n n,k = input().split() input().split() n k = int(n), int(k) int(k) k
import sys

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

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