import sys
input = sys.stdin.readline

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

if P == 1:
    print(0)
else:
    print(N - P) import sys sys input = sys.stdin.readline input sys.stdin.readline sys.stdin sys stdin readline N, P = map(int, input().split()) N map(int, input().split()) map int input().split() ().split () input split P if P == 1:
    print(0)
else:
    print(N - P) P == 1 P 1 print(0) print 0 print(N - P) print N - P N P N, P = map(int, input().split()) map(int, input().split()) N input = sys.stdin.readline sys.stdin.readline input P = map(int, input().split()) map(int, input().split()) P
import sys
input = sys.stdin.readline

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

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