n, k = map(int, input().split())
n = min(n, k - 1)
if n <= k // 2:
    m = 0
else:
    m = n - k // 2
print(m)

84ffc7caa49845ab596c268d626332a666f47a14
<mask token>

<mask token>
if n <= k // 2:
    m = 0
else:
    m = n - k // 2
print(m)

n, k = map(int, input().split())
n = min(n, k - 1)
if n <= k // 2:
    m = 0
else:
    m = n - k // 2
print(m)
