def examA():
    N, K = LI()
    if K==1:
        ans = 0
    else:
        ans = N-K
    print(ans)


from string import digits
import sys,copy,bisect,itertools,math
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
mod = 10**9 + 7
inf = float('inf')

examA() def examA():
    N, K = LI()
    if K==1:
        ans = 0
    else:
        ans = N-K
    print(ans) examA N, K = LI() N LI() LI K if K==1:
        ans = 0
    else:
        ans = N-K
     K==1 K 1 ans = 0 ans 0 ans = N-K ans N-K N K print(ans) print ans from string import digits import sys,copy,bisect,itertools,math sys copy bisect itertools math from heapq import heappop,heappush,heapify from collections import Counter,defaultdict,deque def I(): return int(sys.stdin.readline()) I def LI(): return list(map(int,sys.stdin.readline().split())) LI def LS(): return sys.stdin.readline().split() LS def SI(): return sys.stdin.readline().strip() SI mod = 10**9 + 7 mod 10**9 + 7 10**9 10 9 7 inf = float('inf') inf float('inf') float 'inf' examA() examA def LI(): return list(map(int,sys.stdin.readline().split())) def LI(): return list(map(int,sys.stdin.readline().split())) LI def examA():
    N, K = LI()
    if K==1:
        ans = 0
    else:
        ans = N-K
    print(ans) def examA():
    N, K = LI()
    if K==1:
        ans = 0
    else:
        ans = N-K
    print(ans) examA def LS(): return sys.stdin.readline().split() def LS(): return sys.stdin.readline().split() LS def I(): return int(sys.stdin.readline()) def I(): return int(sys.stdin.readline()) I mod = 10**9 + 7 10**9 + 7 mod inf = float('inf') float('inf') inf def SI(): return sys.stdin.readline().strip() def SI(): return sys.stdin.readline().strip() SI
def examA():
    N, K = LI()
    if K==1:
        ans = 0
    else:
        ans = N-K
    print(ans)


from string import digits
import sys,copy,bisect,itertools,math
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
mod = 10**9 + 7
inf = float('inf')

examA()
