eolymp
bolt
Try our new interface for solving problems
Problems

House in a low tree

House in a low tree

King Julian decided to deal with the housing problems of his subordinates and build one large house for them inside a tree trunk.

This house will have n + 1 floors. Each floor will have 5 square rooms forming a cross. The floors are exactly one above the other. One lemur will live in each room.

prb11121.gif

Lemurs can easily move between adjacent rooms on the same floor. However, in order for them to go up or down one floor, stairs must be built. King Julian decided to build exactly m stairs in the house. Each staircase will connect two rooms that are on top of each other.

Julian wondered how exactly to arrange the stairs in the house. He decided that the location of the stairs would be optimal if there be a minimum sum over all distances between pairs of rooms. The distance between two rooms is the minimum number of steps you need to make to get from one room to another. In one move, you can go to the room next to the side on the same floor, or go up the stairs to the same room on the next floor, if there is such a staircase.

Help Julian find the total distance for the optimal ladder placement.

Input

Two integers n and m (1n106, nmn * 5).

Output

Print one number - the total distance between all pairs of rooms with the optimal arrangement of stairs.

Time limit 1 second
Memory limit 128 MiB
Input example #1
1 1
Output example #1
97
Input example #2
3 10
Output example #2
528
Source 2020 Cycle of Internet Olympiads for schoolchildren, Fifth team contest, Novemver 28, Problem D