import sys

readline = sys.stdin.readline

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

if K == 1:
    print(0)
else:
    print(N - K) import sys sys readline = sys.stdin.readline readline sys.stdin.readline sys.stdin sys stdin readline N, K = map(int, readline().split()) N map(int, readline().split()) map int readline().split() ().split () readline 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 K = map(int, readline().split()) map(int, readline().split()) K N, K = map(int, readline().split()) map(int, readline().split()) N readline = sys.stdin.readline sys.stdin.readline readline
import sys

readline = sys.stdin.readline

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

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