data = list(map(int,input().split()))
n = data[0]
k = data[1]
del data
if k > 1:
    if n >= k:
        print(n-k)
    elif n < k:
        print("1")
else:
    print(0) data = list(map(int,input().split())) data list(map(int,input().split())) list map(int,input().split()) map int input().split() ().split () input split n = data[0] n data[0] data 0 k = data[1] k data[1] data 1 del data data if k > 1:
    if n >= k:
        print(n-k)
    elif n < k:
        print("1")
else:
    print(0) k > 1 k 1 if n >= k:
        print(n-k)
    elif n < k:
        print("1") n >= k n k print(n-k) print n-k n k elif n < k:
        print("1") n < k n k print("1") print "1" print(0) print 0 k = data[1] data[1] k n = data[0] data[0] n data = list(map(int,input().split())) list(map(int,input().split())) data
data = list(map(int,input().split()))
n = data[0]
k = data[1]
del data
if k > 1:
    if n >= k:
        print(n-k)
    elif n < k:
        print("1")
else:
    print(0)