Олимпиадный тренинг

Задача 34777. Lock


Задача

Темы:

The castle is shaped like a large square made up of N × N small squares. The outer squares are towers, they play the main role in protecting the castle from the enemy. For example, if a castle has a size 4 × 4, then it has 12 towers (see the second picture, the towers are highlighted in gray).

The castle guards K regiments, which must be placed on the towers. Several regiments can be placed in one tower, but at the same time, at least one regiment must be in each tower, otherwise the enemy will easily capture this tower. If all the towers are protected, then the enemy chooses to attack one of the four sides of the castle, which is defended by the smallest number of regiments (that is, the total number of regiments in all the towers of this side of the square is minimal).

Determine where the shelves should be placed to best protect the castle.

Input

The first line of the input contains a number N — lock size (2 ≤ N ≤ 100). The second line of the input contains a number K — number of regiments guarding the castle (0 ≤ K ≤ 100).

Imprint

Print a single number — the number of regiments on the least fortified side of the castle with the best placement of regiments. If there are not enough regiments to protect all the towers, print the number 0.

 

Input Output Note
2
5
2 there are four towers and five regiments, so you can put two regiments on one of the towers, but still there will be a side that is protected by only two regiments.
4
15
5 you can arrange the shelves so that each side will be protected by 5 shelves. It will not be possible to protect each side with at least six shelves.