AtCoder Regular Contest 112
B
-- - B
AtCoder
⌀ 822
原题
← AC →
翻译中…

Problem Statement

翻译中…

Snuke has come to Seisu-ya (integer shop) with an integer $B$ in his hand. In Seiyu-ya, you can exchange your integer for another integer by paying money.

翻译中…

More specifically, you can use the following two services any number of times in any order:

翻译中…
  • Pay $1$ yen (the currency of Japan) to multiply your integer by $-1$.
  • Pay $2$ yen to subtract $1$ from your integer.
翻译中…

How many integers are there that Snuke can get for at most $C$ yen?

翻译中…

Constraints

翻译中…
  • $-10^{18}\le B \le 10^{18}$
  • $1\le C \le 10^{18}$
  • All values in input are integers.
翻译中…

Input

翻译中…

Input is given from Standard Input in the following format:

翻译中…

B C

翻译中…

Output

翻译中…

Print the answer.

翻译中…

样例

Input #1
11 2
Output #1
3
There are three numbers that Snuke can get: $-11$, $10$, and $11$, as follows: - by doing nothing, he can get $11$ for $0$ yen; - by multiplying $11$ by $-1$, he can get $-11$ for $1$ yen; - by subtracting $1$ from $11$, he can get $10$ for $2$ yen.
Input #2
0 4
Output #2
4
There are four numbers that Snuke can get: $-2$, $-1$, $0$, and $1$, as follows: - by doing nothing, he can get $0$ for $0$ yen; - by subtracting $1$ from $0$, he can get $-1$ for $2$ yen; - by subtracting $1$ from $0$ and then multiplying by $-1$, he can get $1$ for $3$ yen; - by subtracting $1$ from $0$ and then subtracting $1$ again, he can get $-2$ for $4$ yen.
Input #3
112 20210213
Output #3
20210436
Input #4
-211 1000000000000000000
Output #4
1000000000000000422
题目信息
题号
arc112_b
时间限制
2 s
内存限制
1024 MB

题面与样例版权归 AtCoder 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。