Tanechka is shopping in the toy shop. There are exactly $n$ toys in the shop for sale, the cost of the $i$-th toy is $i$ burles. She wants to choose two toys in such a way that their total cost is $k$ burles. How many ways to do that does she have?

Each toy appears in the shop exactly once. Pairs $(a, b)$ and $(b, a)$ are considered equal. Pairs $(a, b)$, where $a=b$, are not allowed.


-----Input-----

The first line of the input contains two integers $n$, $k$ ($1 \le n, k \le 10^{14}$) — the number of toys and the expected total cost of the pair of toys.


-----Output-----

Print the number of ways to choose the pair of toys satisfying the condition above. Print 0, if Tanechka can choose no pair of toys in such a way that their total cost is $k$ burles.


-----Examples-----
Input
8 5

Output
2

Input
8 15

Output
1

Input
7 20

Output
0

Input
1000000000000 1000000000001

Output
500000000000



-----Note-----

In the first example Tanechka can choose the pair of toys ($1, 4$) or the pair of toys ($2, 3$).

In the second example Tanechka can choose only the pair of toys ($7, 8$).

In the third example choosing any pair of toys will lead to the total cost less than $20$. So the answer is 0.

In the fourth example she can choose the following pairs: $(1, 1000000000000)$, $(2, 999999999999)$, $(3, 999999999998)$, ..., $(500000000000, 500000000001)$. The number of such pairs is exactly $500000000000$.

Difficulty: competition

Starter code:

Solutions:
#!/usr/bin/env python3
n, k = list(map(int, input().split()))
ans = max(0, min(n, k - 1) - k // 2)
print(ans)


n, k = list(map(int, input().split()))
m = k // 2 + 1
l = m - 1
if k % 2 == 0:
    l -= 1
print(max(0, min(l, n - m + 1)))


n, k = list(map(int, input().split()))
if k == 1 or n == 1:
	print(0)
	return
if k > 2 * n - 1:
	print(0)
else:
	left, right = 0, min(n - 1, k - 1)
	while left != right - 1:
		mid = (left + right) // 2
		if k - mid <= n:
			right = mid
		else:
			left = mid
	print(max(0, (min(n, k - 1) - right + 1)) // 2)


a, b = list(map(int, input().split()))

num = (b - 1) // 2
if a < b - 1:
    num -= (b - 1) - a
print(max(0, num))


def ii():
    return int(input())
def mi():
    return list(map(int, input().split()))
def li():
    return list(mi())

n, k = mi()

y = min(n, k - 1)
x = k - y
ans = 0
if x < y:
    dif = y - x
    ans = (dif + 1) // 2
print(ans)


n, m = list(map(int, input().split()))
print(max(min((m + 1) // 2 - 1, n - m // 2), 0))


n, k = list(map(int, input().split()))
print(max(0, min(n, (k - 1) // 2) - max(1, k - n) + 1))


n,m=list(map(int,input().strip().split()))
if (n>=m):
	if (m%2==0):
		print((m-2)//2)
	else:
		print((m-1)//2)
else:
	if (m%2==0):
		l1=((m-2)//2)
		l1=l1-(m-n-1)
	else:
		l1=((m-1)//2)
		l1=l1-(m-n-1)
	if (l1<=0):
		print(0)
	else:
		print (l1)


3

n, k = list(map(int, input().split()))

if 2 * n + 1 < k:
    print(0)
else:
    print(min(n, k - 1) - (k + 2) // 2 + 1)


n, k = map(int, input().split())

if k > n+n-1:
    print(0)
    return

if k <= n:
    print((k-1)//2)
    return

print((n+n-k+1)//2)

USE_STDIO = False

if not USE_STDIO:
    try: import mypc
    except: pass

def main():
    n, k = list(map(int, input().split(' ')))
    minx = max(1, k - n)
    maxx = min(n, (k-1)//2)
    if minx > maxx:
        print(0)
    else:
        print(maxx - minx + 1)

def __starting_point():
    main()




__starting_point()

n,k=map(int,input().split())
ori=k
if n==1 or k<=2:
    print(0)
    return
if k%2==0: k-=1
first=k//2
second=ori-first
if second>n:
    print(0)
    return
print(min(first,n-second+1))

n,m=list(map(int,input().split()))
b=m//2
if m%2==0:
    a=b
else:
    a=b+1
if a ==b:
    a+=1
    b-=1

ans=min(n,m-1)-a+1
if ans<=0:
    print(0)
else:
    print(ans)


#!/bin/python3

a, b = list(map(int, input().split()))

maxval = min(b - 1, a)
minval = b - maxval


d = maxval - minval + 1
if d < 0:
	d = 0

erg = d // 2
print(erg)


from sys import stdin, stdout
from collections import deque

n, k = map(int, stdin.readline().split())
n = min(n, k - 1)

l, r = 0, n + 1
while r - l > 1:
    m = (l + r) >> 1
    
    if k - m <= n:
        r = m
    else:
        l = m

ans = n - r + 1

if not (k & 1) and k // 2 <= n:
    ans -= 1

ans //= 2
stdout.write(str(ans))

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


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

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



n, k = (int(x) for x in input().split())

if n >= k - 1:
    print((k - 1) // 2)
    quit()
else:
    if k % 2 == 0:
        if n <= k // 2:
            print(0)
            quit()
        else:
            print(n - k // 2)
            quit()
    else:
        if n <= k // 2:
            print(0)
            quit()
        else:
            print(n - k // 2)
            quit()


n, m = map(int, input().strip().split())
if m <= n:
    print((m - 1) // 2)
elif 2 * n <= m:
    print(0)
else:
    print((2 * n - m + 1) // 2)

def solve(n, k):
    first = max(1, k - n)
    last = min(k // 2, n)

    return max(0, last - first + k % 2)

def brute(n, k):
    ans = 0
    for a in range(1, n + 1):
        b = k - a
        if a < b and b <= n:
            ans += 1

    return ans

# a < k - a
# 2a < k
# a < n
# k - a <= n
# k - n <= a

# (1, k - 1), (2, k - 2), ... (k / 2, k / 2)
n, k = list(map(int, input().split()))
print(solve(n, k))


n, k = list(map(int, input().split()))

if k % 2 == 0:
    # Gu Su
    down = int(k / 2 + 1)
    if down > n:
        print(0)
        return
    else:
        up = min(k-1, n)
        print(up - down + 1)
else:
    # Ki Su
    down = int((k + 1) / 2)
    if down > n:
        print(0)
        return
    else:
        up = min(k-1, n)
        print(up - down + 1)

# print(down)
# print(up)


n, k = map(int, input().split())
if n >= k - 1:
    print((k - 1) // 2)
else:
    t = k - n
    print(max(0, (n - t + 1) // 2))

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

n, k = list(map(int, input().split()))

if k <= n + 1:
    ans = (k - 1) // 2
else:
    ans = (k - 1) // 2 - (k - n - 1)

print(max(0, ans))