def ball_distribution(N: int, K: int)->int:
    if K == 1:
        return 0
    return N-K


if __name__ == "__main__":
    N, K = map(int, input().split())

    ans = ball_distribution(N, K)
    print(ans) def ball_distribution(N: int, K: int)->int:
    if K == 1:
        return 0
    return N-K ball_distribution if K == 1:
        return 0
     K == 1 K 1 return 0 0 return N-K N-K N K N: int N K: int K if __name__ == "__main__":
    N, K = map(int, input().split())

    ans = ball_distribution(N, K)
    print(ans) __name__ == "__main__" __name__ "__main__" N, K = map(int, input().split()) N map(int, input().split()) map int input().split() ().split () input split K ans = ball_distribution(N, K) ans ball_distribution(N, K) ball_distribution N K print(ans) print ans ans = ball_distribution(N, K) ball_distribution(N, K) ans def ball_distribution(N: int, K: int)->int:
    if K == 1:
        return 0
    return N-K def ball_distribution(N: int, K: int)->int:
    if K == 1:
        return 0
    return N-K ball_distribution K = map(int, input().split()) map(int, input().split()) K N, K = map(int, input().split()) map(int, input().split()) N
def ball_distribution(N: int, K: int)->int:
    if K == 1:
        return 0
    return N-K


if __name__ == "__main__":
    N, K = map(int, input().split())

    ans = ball_distribution(N, K)
    print(ans)
