cho.sh
Notes
Loading...

Painting 1

Time limit

2s

Memory limit

128 MB

Problem

Jimin likes painting. Jimin has a rectangular sheet of paper with width W and height H, and will fold and paint it in the following order.

  1. Fold the paper along the line x = f. The left part is folded onto the right part.
  2. Divide the folded paper horizontally into c + 1 intervals of equal height, then fold it c times in order starting from the top interval.
  3. In the current folded state, let the bottom-left point be (0, 0). Paint the rectangle whose bottom-left corner is (x1, y1) and whose top-right corner is (x2, y2). The paint soaks through every overlapping layer of paper.
  4. Unfold the paper completely.

The figures below show the case W = 5, H = 6, f = 2, c = 2, (x1, y1) = (1, 1), and (x2, y2) = (3, 2).

Given W, H, f, c, x1, y1, x2, and y2, find the area that is not painted after the paper is unfolded.

Input

The first line contains eight integers W, H, f, c, x1, y1, x2, and y2 separated by spaces.

Output

Print the area that is not painted.

Constraints

  • 1 ≤ W, H ≤ 10^9
  • 0 ≤ f ≤ W
  • 0 ≤ c ≤ 1,000
  • c + 1 divides H.
  • 0 ≤ x1 < x2 ≤ max(f, W - f)
  • 0 ≤ y1 < y2 ≤ H / (c + 1)