CF1725A.Accumulation of Dominoes

传统题 时间 2000 ms 内存 256 MiB 3 尝试 1 已通过 1 标签

Accumulation of Dominoes

Pak Chanek has a grid that has NN rows and MM columns. Each row is numbered from 11 to NN from top to bottom. Each column is numbered from 11 to MM from left to right.

Each tile in the grid contains a number. The numbers are arranged as follows:

  • Row 11 contains integers from 11 to MM from left to right.
  • Row 22 contains integers from M+1M+1 to 2×M2 \times M from left to right.
  • Row 33 contains integers from 2×M+12 \times M+1 to 3×M3 \times M from left to right.
  • And so on until row NN.

A domino is defined as two different tiles in the grid that touch by their sides. A domino is said to be tight if and only if the two numbers in the domino have a difference of exactly 11. Count the number of distinct tight dominoes in the grid.

Two dominoes are said to be distinct if and only if there exists at least one tile that is in one domino, but not in the other.

Input

The only line contains two integers NN and MM (1N,M1091 \leq N, M \leq 10^9) — the number of rows and columns in the grid.

Output

An integer representing the number of distinct tight dominoes in the grid.

Note

The picture below is the grid that Pak Chanek has in the first example.

The picture below is an example of a tight domino in the grid.

Samples

3 4
9
2 1
1

在线编程 IDE

建议全屏模式获得最佳体验