n, k = input().split(' ')
n, k = int(n), int(k)
maxval = 1
if k == 1:
    print(0)
else:
    while n - maxval - k + 1 != 0:
        maxval += 1
    print(maxval - 1) n, k = input().split(' ') n input().split(' ') ().split () input split ' ' k n, k = int(n), int(k) n int(n) int n k int(k) int k maxval = 1 maxval 1 if k == 1:
    print(0)
else:
    while n - maxval - k + 1 != 0:
        maxval += 1
    print(maxval - 1) k == 1 k 1 print(0) print 0 while n - maxval - k + 1 != 0:
        maxval += 1
     n - maxval - k + 1 != 0 n - maxval - k + 1 n - maxval - k n - maxval n maxval k 1 0 maxval += 1 maxval 1 print(maxval - 1) print maxval - 1 maxval 1 k = input().split(' ') input().split(' ') k maxval = 1 1 maxval k = int(n), int(k) int(k) k maxval += 1 1 maxval n, k = input().split(' ') input().split(' ') n n, k = int(n), int(k) int(n) n
n, k = input().split(' ')
n, k = int(n), int(k)
maxval = 1
if k == 1:
    print(0)
else:
    while n - maxval - k + 1 != 0:
        maxval += 1
    print(maxval - 1)