题库练习 Pair of Toys
← 上一题 下一题 →

A11870 | Pair of Toys

时间限制1s
内存限制256MB
通过 / 提交0/0

题目描述

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.

输入格式

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.

输出格式

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.

输入输出样例

输入 #1
8 5
输出 #1
2
输入 #2
8 15
输出 #2
1
输入 #3
7 20
输出 #3
0
输入 #4
1000000000000 1000000000001
输出 #4
500000000000
C++ 编辑器
输入
输出