import sys
stdin = sys.stdin

sys.setrecursionlimit(10 ** 7)

def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x) - 1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

n,k = li()

if k == 1:
    print(0)
else:
    print(n-k) import sys sys stdin = sys.stdin stdin sys.stdin sys stdin sys.setrecursionlimit(10 ** 7) sys.setrecursionlimit sys setrecursionlimit 10 ** 7 10 7 def li(): return map(int, stdin.readline().split()) li def li_(): return map(lambda x: int(x) - 1, stdin.readline().split()) li_ def lf(): return map(float, stdin.readline().split()) lf def ls(): return stdin.readline().split() ls def ns(): return stdin.readline().rstrip() ns def lc(): return list(ns()) lc def ni(): return int(stdin.readline()) ni def nf(): return float(stdin.readline()) nf n,k = li() n li() li 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 = li() li() k def ls(): return stdin.readline().split() def ls(): return stdin.readline().split() ls def li(): return map(int, stdin.readline().split()) def li(): return map(int, stdin.readline().split()) li def nf(): return float(stdin.readline()) def nf(): return float(stdin.readline()) nf stdin = sys.stdin sys.stdin stdin def lc(): return list(ns()) def lc(): return list(ns()) lc def li_(): return map(lambda x: int(x) - 1, stdin.readline().split()) def li_(): return map(lambda x: int(x) - 1, stdin.readline().split()) li_ def ns(): return stdin.readline().rstrip() def ns(): return stdin.readline().rstrip() ns def ni(): return int(stdin.readline()) def ni(): return int(stdin.readline()) ni n,k = li() li() n def lf(): return map(float, stdin.readline().split()) def lf(): return map(float, stdin.readline().split()) lf
import sys
stdin = sys.stdin

sys.setrecursionlimit(10 ** 7)

def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x) - 1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

n,k = li()

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