import sys
args = sys.stdin.readlines()
tmp = [int(x) for x in args[0].split(' ')]
N, K = tmp[0], tmp[1]

if K == 1:
    print(0)
    exit()
print(N-K) import sys sys args = sys.stdin.readlines() args sys.stdin.readlines() sys.stdin.readlines sys.stdin sys stdin readlines int(x) for x in args[0].split(' ') for x in args[0].split(' ') x args[0].split(' ') [0].split [0] args 0 split ' ' for x in args[0].split(' ') int(x) int x tmp = [int(x) for x in args[0].split(' ')] tmp [int(x) for x in args[0].split(' ')] N, K = tmp[0], tmp[1] N tmp[0] tmp 0 K tmp[1] tmp 1 if K == 1:
    print(0)
    exit() K == 1 K 1 print(0) print 0 exit() exit print(N-K) print N-K N K args = sys.stdin.readlines() sys.stdin.readlines() args K = tmp[0], tmp[1] tmp[1] K tmp = [int(x) for x in args[0].split(' ')] [int(x) for x in args[0].split(' ')] tmp N, K = tmp[0], tmp[1] tmp[0] N
import sys
args = sys.stdin.readlines()
tmp = [int(x) for x in args[0].split(' ')]
N, K = tmp[0], tmp[1]

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