#!/usr/bin/env python

from collections import deque
import itertools as ite
import sys
import math

sys.setrecursionlimit(1000000)

INF = 10 ** 18
MOD = 10 ** 9 + 7

N, K = map(int, raw_input().split())
if K == 1:
	print 0
else:
	print N - K from collections import deque import itertools as ite itertools import sys sys import math math sys.setrecursionlimit(1000000) sys.setrecursionlimit sys setrecursionlimit 1000000 INF = 10 ** 18 INF 10 ** 18 10 18 MOD = 10 ** 9 + 7 MOD 10 ** 9 + 7 10 ** 9 10 9 7 N, K = map(int, raw_input().split()) N map(int, raw_input().split()) map int raw_input().split() ().split () raw_input split K if K == 1:
	print 0
else:
	print N - K K == 1 K 1 print print N - K N K MOD = 10 ** 9 + 7 10 ** 9 + 7 MOD K = map(int, raw_input().split()) map(int, raw_input().split()) K N, K = map(int, raw_input().split()) map(int, raw_input().split()) N INF = 10 ** 18 10 ** 18 INF
#!/usr/bin/env python

from collections import deque
import itertools as ite
import sys
import math

sys.setrecursionlimit(1000000)

INF = 10 ** 18
MOD = 10 ** 9 + 7

N, K = map(int, raw_input().split())
if K == 1:
	print 0
else:
	print N - K