def main():

    N, K = map(int, input().split())
    if K == 1: return 0

    return N-K



if __name__ == '__main__':
    print(main()) def main():

    N, K = map(int, input().split())
    if K == 1: return 0

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

     K == 1 K 1 return N-K N-K N K if __name__ == '__main__':
    print(main()) __name__ == '__main__' __name__ '__main__' print(main()) print main() main def main():

    N, K = map(int, input().split())
    if K == 1: return 0

    return N-K def main():

    N, K = map(int, input().split())
    if K == 1: return 0

    return N-K main
def main():

    N, K = map(int, input().split())
    if K == 1: return 0

    return N-K



if __name__ == '__main__':
    print(main())
