from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

n,k = inpl()
if k == 1:
    print(0)
else:
    print(n-k) from collections import Counter,defaultdict,deque from heapq import heappop,heappush,heapify import sys,bisect,math,itertools,pprint sys bisect math itertools pprint sys.setrecursionlimit(10**8) sys.setrecursionlimit sys setrecursionlimit 10**8 10 8 mod = 10**9+7 mod 10**9+7 10**9 10 9 7 def inp(): return int(sys.stdin.readline()) inp def inpl(): return list(map(int, sys.stdin.readline().split())) inpl def inpln(n): return list(int(sys.stdin.readline()) for i in range(n)) inpln n n n,k = inpl() n inpl() inpl 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 def inp(): return int(sys.stdin.readline()) def inp(): return int(sys.stdin.readline()) inp n,k = inpl() inpl() n k = inpl() inpl() k def inpln(n): return list(int(sys.stdin.readline()) for i in range(n)) def inpln(n): return list(int(sys.stdin.readline()) for i in range(n)) inpln mod = 10**9+7 10**9+7 mod def inpl(): return list(map(int, sys.stdin.readline().split())) def inpl(): return list(map(int, sys.stdin.readline().split())) inpl
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

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