# 2019 6/15
# diverta 2019 A Ball Distribution

import sys

ball, human = list(map(int, input().split()))

if human == 1:
    print(0)
    sys.exit()
elif ball >= human:
    print(ball - human)
    sys.exit() import sys sys ball, human = list(map(int, input().split())) ball list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split human if human == 1:
    print(0)
    sys.exit()
elif ball >= human:
    print(ball - human)
    sys.exit() human == 1 human 1 print(0) print 0 sys.exit() sys.exit sys exit elif ball >= human:
    print(ball - human)
    sys.exit() ball >= human ball human print(ball - human) print ball - human ball human sys.exit() sys.exit sys exit ball, human = list(map(int, input().split())) list(map(int, input().split())) ball human = list(map(int, input().split())) list(map(int, input().split())) human
# 2019 6/15
# diverta 2019 A Ball Distribution

import sys

ball, human = list(map(int, input().split()))

if human == 1:
    print(0)
    sys.exit()
elif ball >= human:
    print(ball - human)
    sys.exit()