# -*- coding: utf-8 -*-
 
import math
import itertools
import sys
import copy
 
# 入力
#A, B, C, D = map(int, input().split())
#L = list(map(int, input().split()))
#S = list(str(input()))
#N = int(input())
N, K = map(int, input().split())

if K == 1 :
  print (0)
else :
  print (N-(K-1)-1) import math math import itertools itertools import sys sys import copy copy N, K = map(int, input().split()) N map(int, input().split()) map int input().split() ().split () input split K if K == 1 :
  print (0)
else :
  print (N-(K-1)-1) K == 1 K 1 print (0) print 0 print (N-(K-1)-1) print N-(K-1)-1 N-(K-1) N K-1 K 1 1 K = map(int, input().split()) map(int, input().split()) K N, K = map(int, input().split()) map(int, input().split()) N
# -*- coding: utf-8 -*-
 
import math
import itertools
import sys
import copy
 
# 入力
#A, B, C, D = map(int, input().split())
#L = list(map(int, input().split()))
#S = list(str(input()))
#N = int(input())
N, K = map(int, input().split())

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