import sys,collections,math,random;sys.setrecursionlimit(10**7)
def Is(): return [int(x) for x in sys.stdin.readline().split()]
def Ss(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

n,k = Is()
if k == 1 or n == k:
    print(0)
else:
    print(n-k) import sys,collections,math,random sys collections math random sys.setrecursionlimit(10**7) sys.setrecursionlimit sys setrecursionlimit 10**7 10 7 int(x) for x in sys.stdin.readline().split() for x in sys.stdin.readline().split() x sys.stdin.readline().split() sys.stdin.readline().split sys.stdin.readline() sys.stdin.readline sys.stdin sys stdin readline split for x in sys.stdin.readline().split() int(x) int x def Is(): return [int(x) for x in sys.stdin.readline().split()] Is def Ss(): return sys.stdin.readline().split() Ss def I(): return int(sys.stdin.readline()) I def S(): return input() S n,k = Is() n Is() Is k if k == 1 or n == k:
    print(0)
else:
    print(n-k) k == 1 or n == k k == 1 k 1 n == k n k print(0) print 0 print(n-k) print n-k n k def Ss(): return sys.stdin.readline().split() def Ss(): return sys.stdin.readline().split() Ss def S(): return input() def S(): return input() S k = Is() Is() k n,k = Is() Is() n def I(): return int(sys.stdin.readline()) def I(): return int(sys.stdin.readline()) I def Is(): return [int(x) for x in sys.stdin.readline().split()] def Is(): return [int(x) for x in sys.stdin.readline().split()] Is
import sys,collections,math,random;sys.setrecursionlimit(10**7)
def Is(): return [int(x) for x in sys.stdin.readline().split()]
def Ss(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

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