#K8626. Counting Integer Points in a Rectangle

    ID: 36825 Type: Default 1000ms 256MiB

Counting Integer Points in a Rectangle

Counting Integer Points in a Rectangle

You are given a rectangle defined by two opposite corners: (x1, y1) and (x2, y2). The rectangle includes all points \( (i, j) \) such that x1 ≤ i ≤ x2 and y1 ≤ j ≤ y2. Your task is to count the total number of integer lattice points inside or on the border of the rectangle.

The number of integer points can be computed using the formula:

\( (x_2 - x_1 + 1) \times (y_2 - y_1 + 1) \)

It is guaranteed that the input values satisfy x1 ≤ x2 and y1 ≤ y2.

inputFormat

The input consists of a single line containing four space-separated integers x1, y1, x2, y2.

outputFormat

Output a single integer representing the number of integer lattice points that lie inside or on the border of the rectangle.

## sample
1 1 3 3
9