from sys import stdin

def main():
    N, K = map(int, stdin.readline().rstrip().split())

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

main()
 from sys import stdin def main():
    N, K = map(int, stdin.readline().rstrip().split())

    if K == 1:
      print(0)
    else:
      print(N-K) main N, K = map(int, stdin.readline().rstrip().split()) N map(int, stdin.readline().rstrip().split()) map int stdin.readline().rstrip().split() stdin.readline().rstrip().split stdin.readline().rstrip() stdin.readline().rstrip stdin.readline() stdin.readline stdin readline rstrip split K 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 main() main def main():
    N, K = map(int, stdin.readline().rstrip().split())

    if K == 1:
      print(0)
    else:
      print(N-K) def main():
    N, K = map(int, stdin.readline().rstrip().split())

    if K == 1:
      print(0)
    else:
      print(N-K) main
from sys import stdin

def main():
    N, K = map(int, stdin.readline().rstrip().split())

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

main()

