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

def evaluate(N,K):
    if K == 1:
        answer = 0
    else:
        answer = N - K
    return answer

if __name__ == '__main__':
    N, K = input_func()
    answer = evaluate(N,K)
    print(answer) def input_func():
    N, K= map(int,input().split())
    return N, K input_func N, K= map(int,input().split()) N map(int,input().split()) map int input().split() ().split () input split K return N, K return N, K N K def evaluate(N,K):
    if K == 1:
        answer = 0
    else:
        answer = N - K
    return answer evaluate if K == 1:
        answer = 0
    else:
        answer = N - K
     K == 1 K 1 answer = 0 answer 0 answer = N - K answer N - K N K return answer answer N N K K if __name__ == '__main__':
    N, K = input_func()
    answer = evaluate(N,K)
    print(answer) __name__ == '__main__' __name__ '__main__' N, K = input_func() N input_func() input_func K answer = evaluate(N,K) answer evaluate(N,K) evaluate N K print(answer) print answer answer = evaluate(N,K) evaluate(N,K) answer def input_func():
    N, K= map(int,input().split())
    return N, K def input_func():
    N, K= map(int,input().split())
    return N, K input_func def evaluate(N,K):
    if K == 1:
        answer = 0
    else:
        answer = N - K
    return answer def evaluate(N,K):
    if K == 1:
        answer = 0
    else:
        answer = N - K
    return answer evaluate N, K = input_func() input_func() N K = input_func() input_func() K
def input_func():
    N, K= map(int,input().split())
    return N, K

def evaluate(N,K):
    if K == 1:
        answer = 0
    else:
        answer = N - K
    return answer

if __name__ == '__main__':
    N, K = input_func()
    answer = evaluate(N,K)
    print(answer)