'''
Created on 2020/08/20

@author: harurun
'''
def main():
  import sys
  pin=sys.stdin.readline
  pout=sys.stdout.write
  perr=sys.stderr.write
  
  N,K=map(int,pin().split())
  if K==1:
    print(0)
    return 
  t=N-K 
  print(t)
  return 

main() '''
Created on 2020/08/20

@author: harurun
''' def main():
  import sys
  pin=sys.stdin.readline
  pout=sys.stdout.write
  perr=sys.stderr.write
  
  N,K=map(int,pin().split())
  if K==1:
    print(0)
    return 
  t=N-K 
  print(t)
  return  main import sys sys pin=sys.stdin.readline pin sys.stdin.readline sys.stdin sys stdin readline pout=sys.stdout.write pout sys.stdout.write sys.stdout sys stdout write perr=sys.stderr.write perr sys.stderr.write sys.stderr sys stderr write N,K=map(int,pin().split()) N map(int,pin().split()) map int pin().split() ().split () pin split K if K==1:
    print(0)
    return 
   K==1 K 1 print(0) print 0 return t=N-K t N-K N K print(t) print t return main() main def main():
  import sys
  pin=sys.stdin.readline
  pout=sys.stdout.write
  perr=sys.stderr.write
  
  N,K=map(int,pin().split())
  if K==1:
    print(0)
    return 
  t=N-K 
  print(t)
  return  def main():
  import sys
  pin=sys.stdin.readline
  pout=sys.stdout.write
  perr=sys.stderr.write
  
  N,K=map(int,pin().split())
  if K==1:
    print(0)
    return 
  t=N-K 
  print(t)
  return  main
'''
Created on 2020/08/20

@author: harurun
'''
def main():
  import sys
  pin=sys.stdin.readline
  pout=sys.stdout.write
  perr=sys.stderr.write
  
  N,K=map(int,pin().split())
  if K==1:
    print(0)
    return 
  t=N-K 
  print(t)
  return 

main()