import sys
data = sys.stdin.readlines()
data = data[0].split()
N = int(data[0])
K = int(data[1])
if K == 1:
    print(0)
else:
    print(N-K) import sys sys data = sys.stdin.readlines() data sys.stdin.readlines() sys.stdin.readlines sys.stdin sys stdin readlines data = data[0].split() data data[0].split() [0].split [0] data 0 split N = int(data[0]) N int(data[0]) int data[0] data 0 K = int(data[1]) K int(data[1]) int data[1] data 1 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 = int(data[1]) int(data[1]) K N = int(data[0]) int(data[0]) N data = sys.stdin.readlines() sys.stdin.readlines() data data = data[0].split() data[0].split() data
import sys
data = sys.stdin.readlines()
data = data[0].split()
N = int(data[0])
K = int(data[1])
if K == 1:
    print(0)
else:
    print(N-K)