output_description: Print the maximum possible difference in the number of balls received.
  
  * * *
input_description: Input is given from Standard Input in the following format:
  
      
      
      N K
attempt: #    !/usr/bin/env python3
  #    encoding: UTF-8
  #    Modified: <15/Jun/2019 05:31:28 PM>
  
  
  #    ✪ H4WK3yE乡
  #    Mohd. Farhan Tahir
  #    Indian Institute Of Information Technology (IIIT), Gwalior
  
  
  import sys
  import os
  from io import IOBase, BytesIO
  
  
  def main():
      n, k = get_ints()
      if k == 1:
          print(0)
          return
      left = n - k
      print(left)
  
  
  BUFSIZE = 8192
  
  
  class FastIO(BytesIO):
      newlines = 0
  
      def __init__(self, file):
          self._file = file
          self._fd = file.fileno()
          self.writable = "x" in file.mode or "w" in file.mode
          self.write = super(FastIO, self).write if self.writable else None
  
      def _fill(self):
          s = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
          self.seek((self.tell(), self.seek(0, 2), super(FastIO, self).write(s))[0])
          return s
  
      def read(self):
          while self._fill():
              pass
          return super(FastIO, self).read()
  
      def readline(self):
          while self.newlines == 0:
              s = self._fill()
              self.newlines = s.count(b"\n") + (not s)
          self.newlines -= 1
          return super(FastIO, self).readline()
  
      def flush(self):
          if self.writable:
              os.write(self._fd, self.getvalue())
              self.truncate(0), self.seek(0)
  
  
  class IOWrapper(IOBase):
      def __init__(self, file):
          py2 = round(0.5)
          self.buffer = FastIO(file)
          self.flush = self.buffer.flush
          self.writable = self.buffer.writable
          if py2:
              self.write = self.buffer.write
              self.read = self.buffer.read
              self.readline = self.buffer.readline
          else:
              self.write = lambda s: self.buffer.write(s.encode("ascii"))
              self.read = lambda: self.buffer.read().decode("ascii")
              self.readline = lambda: self.buffer.readline().decode("ascii")
  
  
  sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
  
  
  def get_array():
      return list(map(int, sys.stdin.readline().split()))
  
  
  def get_ints():
      return map(int, sys.stdin.readline().split())
  
  
  def input():
      return sys.stdin.readline().strip()
  
  
  if __name__ == "__main__":
      main()
  
problem_description: Statement
  
  Takahashi is distributing N balls to K persons.
  
  If each person has to receive at least one ball, what is the maximum possible
  difference in the number of balls received between the person with the most
  balls and the person with the fewest balls?
samples: [{"input": "3 2", "output": "1\n    \n\nThe only way to distribute three balls to two persons so that each of them\nreceives at least one ball is to give one ball to one person and give two\nballs to the other person.\n\nThus, the maximum possible difference in the number of balls received is 1.\n\n* * *"}, {"input": "3 1", "output": "0\n    \n\nWe have no choice but to give three balls to the only person, in which case\nthe difference in the number of balls received is 0.\n\n* * *"}, {"input": "8 5", "output": "3\n    \n\nFor example, if we give 1, 4, 1, 1, 1 balls to the five persons, the number of\nballs received between the person with the most balls and the person with the\nfewest balls would be 3, which is the maximum result."}]