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

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

if '__main__' == __name__:
    resolve()