import heapq
from sys import stdin
input = stdin.readline

#入力
# s = input()[0:-1]
# n = int(input())
n,k = map(int, input().split())
# a = list(map(int,input().split()))
# a = [int(input()) for i in range()]


# ab=[]
# for i in range():
#     a,b = map(int, input().split())
#     ab.append([a,b])


     
def main():
  if k ==1 :
      print(0)
  else:
      print(n-k)
    

if __name__ == '__main__':
    main() import heapq heapq from sys import stdin input = stdin.readline input stdin.readline stdin readline n,k = map(int, input().split()) n map(int, input().split()) map int input().split() ().split () input split k def main():
  if k ==1 :
      print(0)
  else:
      print(n-k)
     main if k ==1 :
      print(0)
  else:
      print(n-k)
     k ==1 k 1 print(0) print 0 print(n-k) print n-k n k if __name__ == '__main__':
    main() __name__ == '__main__' __name__ '__main__' main() main def main():
  if k ==1 :
      print(0)
  else:
      print(n-k)
     def main():
  if k ==1 :
      print(0)
  else:
      print(n-k)
     main input = stdin.readline stdin.readline input n,k = map(int, input().split()) map(int, input().split()) n k = map(int, input().split()) map(int, input().split()) k
import heapq
from sys import stdin
input = stdin.readline

#入力
# s = input()[0:-1]
# n = int(input())
n,k = map(int, input().split())
# a = list(map(int,input().split()))
# a = [int(input()) for i in range()]


# ab=[]
# for i in range():
#     a,b = map(int, input().split())
#     ab.append([a,b])


     
def main():
  if k ==1 :
      print(0)
  else:
      print(n-k)
    

if __name__ == '__main__':
    main()