import sys
input = sys.stdin.readline
#n = int(input()) 
n,k = (int(i) for i in input().split())
if k==1:
    ans=0
else:
    res=n-(k-1)
    ans=res-1
print(ans) import sys sys input = sys.stdin.readline input sys.stdin.readline sys.stdin sys stdin readline int(i) for i in input().split() for i in input().split() i input().split() ().split () input split for i in input().split() int(i) int i n,k = (int(i) for i in input().split()) n (int(i) for i in input().split()) k if k==1:
    ans=0
else:
    res=n-(k-1)
    ans=res-1 k==1 k 1 ans=0 ans 0 res=n-(k-1) res n-(k-1) n k-1 k 1 ans=res-1 ans res-1 res 1 print(ans) print ans input = sys.stdin.readline sys.stdin.readline input res=n-(k-1) n-(k-1) res k = (int(i) for i in input().split()) (int(i) for i in input().split()) k ans=res-1 res-1 ans n,k = (int(i) for i in input().split()) (int(i) for i in input().split()) n ans=0 0 ans
import sys
input = sys.stdin.readline
#n = int(input()) 
n,k = (int(i) for i in input().split())
if k==1:
    ans=0
else:
    res=n-(k-1)
    ans=res-1
print(ans)