from sys import stdin

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


if __name__ == '__main__':
    N, K = [int(x) for x in stdin.readline().rstrip().split()]
    print(solve(N, K))
    
    # test
    # print(1 == solve(3,2))
    # print(0 == solve(3,1))
    # print(3 == solve(8,5)) from sys import stdin def solve(N, K):
    if K == 1:
        return 0
    else:
        return N - K solve if K == 1:
        return 0
    else:
        return N - K K == 1 K 1 return 0 0 return N - K N - K N K N N K K if __name__ == '__main__':
    N, K = [int(x) for x in stdin.readline().rstrip().split()]
    print(solve(N, K))
    
    # test
    # print(1 == solve(3,2))
    # print(0 == solve(3,1))
    # print(3 == solve(8,5)) __name__ == '__main__' __name__ '__main__' int(x) for x in stdin.readline().rstrip().split() for x in stdin.readline().rstrip().split() x stdin.readline().rstrip().split() stdin.readline().rstrip().split stdin.readline().rstrip() stdin.readline().rstrip stdin.readline() stdin.readline stdin readline rstrip split for x in stdin.readline().rstrip().split() int(x) int x N, K = [int(x) for x in stdin.readline().rstrip().split()] N [int(x) for x in stdin.readline().rstrip().split()] K print(solve(N, K)) print solve(N, K) solve N K N, K = [int(x) for x in stdin.readline().rstrip().split()] [int(x) for x in stdin.readline().rstrip().split()] N def solve(N, K):
    if K == 1:
        return 0
    else:
        return N - K def solve(N, K):
    if K == 1:
        return 0
    else:
        return N - K solve K = [int(x) for x in stdin.readline().rstrip().split()] [int(x) for x in stdin.readline().rstrip().split()] K
from sys import stdin

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


if __name__ == '__main__':
    N, K = [int(x) for x in stdin.readline().rstrip().split()]
    print(solve(N, K))
    
    # test
    # print(1 == solve(3,2))
    # print(0 == solve(3,1))
    # print(3 == solve(8,5))