409228: GYM103463 H Hsueh- and keyboard

Memory Limit:512 MB Time Limit:4 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

H. Hsueh- and keyboardtime limit per test4 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard output

Hsueh- has a keyboard.

There is a string which has $$$x$$$ characters in the textarea.

At present, Hsueh- wants to see a string of length exactly $$$n$$$ in the textarea.

You can use the following operations to meet Hsueh-'s requirements.

  • Strike the keyboard once, enter a character.
  • Strike the keyboard twice(Ctrl + A), select all characters in the textarea.
  • Strike the keyboard twice(Ctrl + C), copy the selected character to the clipboard.
  • Strike the keyboard twice(Ctrl + V), paste the characters which in the clipboard(Do not empty the clipboard).
  • Strike the keyboard once(Backspace), delete character at the end of the textarea or delete the selected character if some characters are selected.

Hsueh- wants to know the minimum number of strokes required to see a string of length exactly $$$n$$$ in the textarea.

What is different from your traditional perception is, if you press Ctrl + A to select all characters and then enter a character or paste some characters, the selected characters will not be deleted. In other words, if you select all characters in the textarea and then enter a character or paste some characters, it will not replace the selected characters but append the characters you enter or paste at the end.

Input

The first line contains two integers $$$x, n(0 \leq x \leq 10^6, 1 \leq n \leq 10^6)$$$, denoting the length of the string which originally appeared in the textarea and the length of the string which Hsueh- wants to see.

Output

Print a single integer in one line: the minimum number of strokes required to see a string of length exactly $$$n$$$ in the textarea.

ExamplesInput
1 4
Output
3
Input
100 199
Output
7

加入题单

算法标签: