{"raw_statement":[{"iden":"statement","content":"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?\n\nEach 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."},{"iden":"input","content":"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."},{"iden":"output","content":"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."},{"iden":"examples","content":"Input\n\n8 5\n\nOutput\n\n2\n\nInput\n\n8 15\n\nOutput\n\n1\n\nInput\n\n7 20\n\nOutput\n\n0\n\nInput\n\n1000000000000 1000000000001\n\nOutput\n\n500000000000"},{"iden":"note","content":"In the first example Tanechka can choose the pair of toys ($1, 4$) or the pair of toys ($2, 3$).\n\nIn the second example Tanechka can choose only the pair of toys ($7, 8$).\n\nIn the third example choosing any pair of toys will lead to the total cost less than $20$. So the answer is _0_.\n\nIn 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$."}],"translated_statement":[{"iden":"statement","content":"Tanechka 在玩具店购物。店里恰好有 $n$ 个玩具待售，第 $i$ 个玩具的价格为 $i$ 布尔。她希望选择两个玩具，使得它们的总价格为 $k$ 布尔。有多少种选择方式？\n\n每个玩具在店里仅出现一次。对 $(a, b)$ 和 $(b, a)$ 视为相同。不允许选择 $a = b$ 的对 $(a, b)$。\n\n输入的第一行包含两个整数 $n$, $k$ ($1 lt.eq n, k lt.eq 10^(14)$) —— 玩具的数量和期望的玩具对总价格。\n\n请输出满足上述条件的玩具对的选择方式数量。如果 Tanechka 无法选择任何一对玩具使其总价格为 $k$ 布尔，请输出 _0_。\n\n在第一个例子中，Tanechka 可以选择玩具对 $(1, 4)$ 或 $(2, 3)$。\n\n在第二个例子中，Tanechka 只能选择玩具对 $(7, 8)$。\n\n在第三个例子中，选择任意一对玩具都会导致总价格小于 $20$。因此答案为 _0_。\n\n在第四个例子中，她可以选择以下对：$(1, 1000000000000)$, $(2, 999999999999)$, $(3, 999999999998)$, ..., $(500000000000, 500000000001)$。这样的对的数量恰好为 $500000000000$。\n\n"},{"iden":"input","content":"输入的第一行包含两个整数 $n$, $k$ ($1 lt.eq n, k lt.eq 10^(14)$) —— 玩具的数量和期望的玩具对总价格。"},{"iden":"output","content":"请输出满足上述条件的玩具对的选择方式数量。如果 Tanechka 无法选择任何一对玩具使其总价格为 $k$ 布尔，请输出 _0_。"},{"iden":"examples","content":"输入8 5输出2输入8 15输出1输入7 20输出0输入1000000000000 1000000000001输出500000000000"},{"iden":"note","content":"在第一个例子中，Tanechka 可以选择玩具对 $(1, 4)$ 或 $(2, 3)$。在第二个例子中，Tanechka 只能选择玩具对 $(7, 8)$。在第三个例子中，选择任意一对玩具都会导致总价格小于 $20$。因此答案为 _0_。在第四个例子中，她可以选择以下对：$(1, 1000000000000)$, $(2, 999999999999)$, $(3, 999999999998)$, ..., $(500000000000, 500000000001)$。这样的对的数量恰好为 $500000000000$。"}],"sample_group":[],"show_order":[],"formal_statement":"**Definitions**  \nLet $ n, k \\in \\mathbb{Z}^+ $ with $ 1 \\leq n, k \\leq 10^{14} $.  \nLet $ T = \\{1, 2, \\dots, n\\} $ be the set of toy costs.  \nLet $ P = \\{ \\{a, b\\} \\subseteq T \\mid a < b \\text{ and } a + b = k \\} $ be the set of valid unordered pairs.\n\n**Constraints**  \n1. $ a, b \\in T $  \n2. $ a \\neq b $  \n3. $ a + b = k $  \n4. $ a < b $ (to enforce unordered pairs without duplication)\n\n**Objective**  \nCompute $ |P| $, the number of unordered pairs $ \\{a, b\\} $ such that $ a + b = k $, $ 1 \\leq a < b \\leq n $.\n\n---\n\n**Formal Expression:**  \n$$\n|P| = \\left| \\left\\{ a \\in \\mathbb{Z} \\mid 1 \\leq a < \\frac{k}{2},\\ a \\leq n,\\ k - a \\leq n,\\ k - a > a \\right\\} \\right|\n$$\n\nEquivalently, define the range of valid $ a $:  \nLet $ a_{\\min} = \\max(1, k - n) $,  \nLet $ a_{\\max} = \\min\\left( \\left\\lfloor \\frac{k-1}{2} \\right\\rfloor, n \\right) $.  \n\nThen:  \n$$\n|P| = \\max\\left(0,\\ a_{\\max} - a_{\\min} + 1 \\right)\n$$","simple_statement":null,"has_page_source":false}