#  --*-coding:utf-8-*--

def f(N, K):
    return N - K if K > 1 else 0



def main():
    N, K  = map(int, input().split())
    print(f(N, K))


if __name__ == '__main__':
    main() def f(N, K):
    return N - K if K > 1 else 0 f return N - K if K > 1 else 0 N - K if K > 1 else 0 K > 1 K 1 N - K N K 0 N N K K def main():
    N, K  = map(int, input().split())
    print(f(N, K)) main N, K  = map(int, input().split()) N map(int, input().split()) map int input().split() ().split () input split K print(f(N, K)) print f(N, K) f N K if __name__ == '__main__':
    main() __name__ == '__main__' __name__ '__main__' main() main def main():
    N, K  = map(int, input().split())
    print(f(N, K)) def main():
    N, K  = map(int, input().split())
    print(f(N, K)) main def f(N, K):
    return N - K if K > 1 else 0 def f(N, K):
    return N - K if K > 1 else 0 f
#  --*-coding:utf-8-*--

def f(N, K):
    return N - K if K > 1 else 0



def main():
    N, K  = map(int, input().split())
    print(f(N, K))


if __name__ == '__main__':
    main()
