import sys
sys.setrecursionlimit(10**7)
INTMAX = 9223372036854775807
INTMIN = -9223372036854775808
MOD = 1000000007
def POW(x, y): return pow(x, y, MOD)
def INV(x, m=MOD): return pow(x, m - 2, m)
def DIV(x, y, m=MOD): return (x * INV(y, m)) % m
def LI(): return [int(x) for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LS(): return input().split()
def II(): return int(input())

N,K=LI()

if K == 1:
    print(0)
else:
    print(N-K) import sys sys sys.setrecursionlimit(10**7) sys.setrecursionlimit sys setrecursionlimit 10**7 10 7 INTMAX = 9223372036854775807 INTMAX 9223372036854775807 INTMIN = -9223372036854775808 INTMIN -9223372036854775808 MOD = 1000000007 MOD 1000000007 def POW(x, y): return pow(x, y, MOD) POW x x y y def INV(x, m=MOD): return pow(x, m - 2, m) INV x x m=MOD m MOD def DIV(x, y, m=MOD): return (x * INV(y, m)) % m DIV x x y y m=MOD m MOD int(x) for x in input().split() for x in input().split() x input().split() ().split () input split for x in input().split() int(x) int x def LI(): return [int(x) for x in input().split()] LI float(x) for x in input().split() for x in input().split() x input().split() ().split () input split for x in input().split() float(x) float x def LF(): return [float(x) for x in input().split()] LF def LS(): return input().split() LS def II(): return int(input()) II 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 def LF(): return [float(x) for x in input().split()] def LF(): return [float(x) for x in input().split()] LF INTMAX = 9223372036854775807 9223372036854775807 INTMAX def LI(): return [int(x) for x in input().split()] def LI(): return [int(x) for x in input().split()] LI N,K=LI() LI() N def II(): return int(input()) def II(): return int(input()) II def INV(x, m=MOD): return pow(x, m - 2, m) def INV(x, m=MOD): return pow(x, m - 2, m) INV INTMIN = -9223372036854775808 -9223372036854775808 INTMIN def DIV(x, y, m=MOD): return (x * INV(y, m)) % m def DIV(x, y, m=MOD): return (x * INV(y, m)) % m DIV K=LI() LI() K def POW(x, y): return pow(x, y, MOD) def POW(x, y): return pow(x, y, MOD) POW MOD = 1000000007 1000000007 MOD def LS(): return input().split() def LS(): return input().split() LS
import sys
sys.setrecursionlimit(10**7)
INTMAX = 9223372036854775807
INTMIN = -9223372036854775808
MOD = 1000000007
def POW(x, y): return pow(x, y, MOD)
def INV(x, m=MOD): return pow(x, m - 2, m)
def DIV(x, y, m=MOD): return (x * INV(y, m)) % m
def LI(): return [int(x) for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LS(): return input().split()
def II(): return int(input())

N,K=LI()

if K == 1:
    print(0)
else:
    print(N-K)
