# -*- coding: utf-8 -*-

import sys
import copy

sys.setrecursionlimit(1000000)

# input = sys.stdin.readline

# ~~~~~~~~~~~~~~~~~~~~~_(＾～＾ ｣ ∠)_~~~~~~~~~~~~~~~~~~~~~

N, K = map(int, input().split())

if K == 1:
    print(0)
else:
    print(N - K) import sys sys import copy copy sys.setrecursionlimit(1000000) sys.setrecursionlimit sys setrecursionlimit 1000000 N, K = map(int, input().split()) N map(int, input().split()) map int input().split() ().split () input split K 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 N, K = map(int, input().split()) map(int, input().split()) N K = map(int, input().split()) map(int, input().split()) K
# -*- coding: utf-8 -*-

import sys
import copy

sys.setrecursionlimit(1000000)

# input = sys.stdin.readline

# ~~~~~~~~~~~~~~~~~~~~~_(＾～＾ ｣ ∠)_~~~~~~~~~~~~~~~~~~~~~

N, K = map(int, input().split())

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