Firefighting Heroes

In a small town, there are N × N houses in a square grid, indexed by row i, and column, j: (i, j). For 1 ≤ i,j ≤ N. (1,1) is the house in the top left corner. At time 0, a fire breaks out at the house indexed by (1, C ), where C ≤ N /2. During each subsequent time interval [t, t + 1], the fire fighters defend a house which is not yet on fire while the fire spreads to all undefended neighbors of each house which was on fire at time t. Once a house is defended, it remains so all the time. The process ends when the fire can no longer spread. At most how many houses can be saved by the fire fighters? A house indexed by (a, b) is a neighbor of a house indexed by (c, d) if |a − c| + |b − d| ≤ 1. Input A number of inputs (< 1000) with three space separated integers N, C (1 ≤ N ≤ 1000000, 1 ≤ C ≤ N /2). Output Output one line per input, the answer. Sample Input 21 31 Sample Output 2 6