import sys
from sys import stdin

n, k = map(int, stdin.readline().rstrip().split())

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

n, k = map(int, stdin.readline().rstrip().split())

if k == 1:
    print(0)
else:
    print(n-k)