import sys
import math 
ni = lambda: int(ns())
na = lambda: list(map(int, input().split()))
ns = lambda: input()
N,K = na()


if K==1:
    print(0)
else:
    print(N-K) import sys sys import math math ni = lambda: int(ns()) ni lambda: int(ns()) int(ns()) int ns() ns na = lambda: list(map(int, input().split())) na lambda: list(map(int, input().split())) list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split ns = lambda: input() ns lambda: input() input() input N,K = na() N na() na 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 N,K = na() na() N ns = lambda: input() lambda: input() ns ni = lambda: int(ns()) lambda: int(ns()) ni K = na() na() K na = lambda: list(map(int, input().split())) lambda: list(map(int, input().split())) na
import sys
import math 
ni = lambda: int(ns())
na = lambda: list(map(int, input().split()))
ns = lambda: input()
N,K = na()


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