# -*- coding: utf-8 -*-
import sys
N, M= map(int, raw_input().split())
if M == 1:
	result = 0
else:
	result = N-M
print result import sys sys N, M= map(int, raw_input().split()) N map(int, raw_input().split()) map int raw_input().split() ().split () raw_input split M if M == 1:
	result = 0
else:
	result = N-M M == 1 M 1 result = 0 result 0 result = N-M result N-M N M print N, M= map(int, raw_input().split()) map(int, raw_input().split()) N M= map(int, raw_input().split()) map(int, raw_input().split()) M result = 0 0 result result = N-M N-M result
# -*- coding: utf-8 -*-
import sys
N, M= map(int, raw_input().split())
if M == 1:
	result = 0
else:
	result = N-M
print result