from collections import defaultdict
from collections import deque
from string import ascii_uppercase
import sys, bisect, math, heapq

stdin = sys.stdin
read_int = lambda : list(map(int,stdin.readline().split()))
read_str = lambda : stdin.readline().rstrip()

N, K = read_int()

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

if __name__ == "__main__":
    print(solve()) from collections import defaultdict from collections import deque from string import ascii_uppercase import sys, bisect, math, heapq sys bisect math heapq stdin = sys.stdin stdin sys.stdin sys stdin read_int = lambda : list(map(int,stdin.readline().split())) read_int lambda : list(map(int,stdin.readline().split())) list(map(int,stdin.readline().split())) list map(int,stdin.readline().split()) map int stdin.readline().split() stdin.readline().split stdin.readline() stdin.readline stdin readline split read_str = lambda : stdin.readline().rstrip() read_str lambda : stdin.readline().rstrip() stdin.readline().rstrip() stdin.readline().rstrip stdin.readline() stdin.readline stdin readline rstrip N, K = read_int() N read_int() read_int K def solve():
    if K == 1:
        return 0
    ans = N - K
    return ans solve if K == 1:
        return 0
     K == 1 K 1 return 0 0 ans = N - K ans N - K N K return ans ans if __name__ == "__main__":
    print(solve()) __name__ == "__main__" __name__ "__main__" print(solve()) print solve() solve read_int = lambda : list(map(int,stdin.readline().split())) lambda : list(map(int,stdin.readline().split())) read_int K = read_int() read_int() K N, K = read_int() read_int() N stdin = sys.stdin sys.stdin stdin def solve():
    if K == 1:
        return 0
    ans = N - K
    return ans def solve():
    if K == 1:
        return 0
    ans = N - K
    return ans solve read_str = lambda : stdin.readline().rstrip() lambda : stdin.readline().rstrip() read_str
from collections import defaultdict
from collections import deque
from string import ascii_uppercase
import sys, bisect, math, heapq

stdin = sys.stdin
read_int = lambda : list(map(int,stdin.readline().split()))
read_str = lambda : stdin.readline().rstrip()

N, K = read_int()

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

if __name__ == "__main__":
    print(solve())