Please subscribe to the official Codeforces channel in Telegram via the link: https://t.me/codeforces_official.
×

Virtual contest is a way to take part in past contest, as close as possible to participation on time. It is supported only ACM-ICPC mode for virtual contests.
If you've seen these problems, a virtual contest is not for you - solve these problems in the archive.
If you just want to solve some problem from a contest, a virtual contest is not for you - solve this problem in the archive.
Never use someone else's code, read the tutorials or communicate with other person during a virtual contest.

No tag edit access

B. Pair of Toys

time limit per test

1 secondmemory limit per test

256 megabytesinput

standard inputoutput

standard outputTanechka 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$$$.

Codeforces (c) Copyright 2010-2018 Mike Mirzayanov

The only programming contests Web 2.0 platform

Server time: Dec/12/2018 16:22:50 (d2).

Desktop version, switch to mobile version.

Supported by

User lists

Name |
---|