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

    if K == 1:
        print(0)
    else:
        print(N - (K - 1) - 1)
        
if __name__ == "__main__":
    main() def main():
    N, K = map(int, input().split())

    if K == 1:
        print(0)
    else:
        print(N - (K - 1) - 1)
         main N, K = map(int, input().split()) N map(int, input().split()) map int input().split() ().split () input split K if K == 1:
        print(0)
    else:
        print(N - (K - 1) - 1)
         K == 1 K 1 print(0) print 0 print(N - (K - 1) - 1) print N - (K - 1) - 1 N - (K - 1) N K - 1 K 1 1 if __name__ == "__main__":
    main() __name__ == "__main__" __name__ "__main__" main() main def main():
    N, K = map(int, input().split())

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

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

    if K == 1:
        print(0)
    else:
        print(N - (K - 1) - 1)
        
if __name__ == "__main__":
    main()