import sys

# from collections import Counter, deque, defaultdict
# from itertools import accumulate, permutations, combinations, takewhile, compress, cycle
# from functools import reduce
# from math import ceil, floor, log10, log2, factorial

sys.setrecursionlimit(1000000)
MOD = 10 ** 9 + 7

N, K = [int(x) for x in input().split()]

print(N - K if K != 1 else 0) import sys sys sys.setrecursionlimit(1000000) sys.setrecursionlimit sys setrecursionlimit 1000000 MOD = 10 ** 9 + 7 MOD 10 ** 9 + 7 10 ** 9 10 9 7 int(x) for x in input().split() for x in input().split() x input().split() ().split () input split for x in input().split() int(x) int x N, K = [int(x) for x in input().split()] N [int(x) for x in input().split()] K print(N - K if K != 1 else 0) print N - K if K != 1 else 0 K != 1 K 1 N - K N K 0 N, K = [int(x) for x in input().split()] [int(x) for x in input().split()] N MOD = 10 ** 9 + 7 10 ** 9 + 7 MOD K = [int(x) for x in input().split()] [int(x) for x in input().split()] K
import sys

# from collections import Counter, deque, defaultdict
# from itertools import accumulate, permutations, combinations, takewhile, compress, cycle
# from functools import reduce
# from math import ceil, floor, log10, log2, factorial

sys.setrecursionlimit(1000000)
MOD = 10 ** 9 + 7

N, K = [int(x) for x in input().split()]

print(N - K if K != 1 else 0)
