This page is still under construction.

Parts of this page are still being built. What you see may change.

Fossil Excavation Event

Time limit0.5sMemory limit1024 MB

Summary
Count grid cells (x,y) in [-n,n]^2 where max(|x|,|y|) differs from max(|x|,|y-k|), for n,k up to 1e9.
Level

Medium7 of 10

Topics
Math, Geometry, Implementation, Brute force
Solved
No attempts yet

Problem

[Figure] The field with n=1n=1, k=2k=2

To mark the opening of the Yonsei University freshman programming contest, Gukryeol planned to hold a fossil excavation event at the field near the engineering building. The fossil excavation event is an event where participants find fossils buried in the field near the engineering building. However, an experiment inside the engineering building contaminated part of the field with a substance that is extremely dangerous to the human body.

Because of this, Gukryeol postponed the fossil excavation event and decided to carry the uncontaminated soil from the field to another place before holding the event. Since he planned to hire an outside company for this work, he had to know the cost of moving the soil in advance, and to compute it he needed the number of cells that contain uncontaminated soil.

The field is a grid of [−n,n]×[−n,n][-n,n] \times [-n,n], where the bottom-left cell is (−n,−n)(-n,-n) and the top-right cell is (n,n)(n,n). If some xx, yy satisfy max⁡(∣x∣,∣y∣)≠max⁡(∣x∣,∣y−k∣)\max(\left| x \right|, \left| y \right|) \ne \max(\left| x \right|, \left| y-k \right|), then the soil at (x,y)(x,y) is uncontaminated clean soil; otherwise it is contaminated soil. For example, if the field is given as n=1n=1, k=2k=2 as in the [Figure], the number of cells that contain uncontaminated soil is 6 in total.

Given nn and kk, find the number of cells that contain uncontaminated soil.

Input

The first line gives nn and kk. (1≤n,k≤1 000 000 0001 \le n, k \le 1 \, 000 \, 000 \, 000)

Output

Print the number of cells that contain uncontaminated soil.

Examples3

  1. Example 1

    Input
    1 1
    
    Expected output
    5
    
  2. Example 2

    Input
    1 2
    
    Expected output
    6
    
  3. Example 3

    Input
    1 3
    
    Expected output
    9