Laser
Scientists in Byteland have developed a new laser to aid in their research. Before it can be used practically, the laser must undergo testing at a secret site in Byteland.
The testing area is a rectangle measuring (N-1) by (M-1) meters, divided into squares of 1 m(^2) by vertical and horizontal lines. This area can be visualized as a grid with (N-1) rows and (M-1) columns. The horizontal lines are numbered from bottom to top starting at one, and the vertical lines from left to right starting at one. Thus, each intersection of a vertical and horizontal line (totaling (N*M)) can be identified by a pair of numbers ((X, Y)), which we refer to as the coordinates of a point. Here, (X) is the vertical line number, and (Y) is the horizontal line number at the intersection.
The laser is positioned at the coordinates ((A, B)). At every other intersection point, sensors are installed, which activate when the laser beam passes through them. The laser can fire from ((A, B)) to any other point on the grid where a sensor is located. Only the sensors along the line segment between these two points will be triggered (the segment starts at the laser's coordinates ((A, B)) and ends at the target point's coordinates). Note that all sensors and the laser are on the same plane.
Figure No.1. Description of the first example. N = 3, M = 6, A = 1, B = 1
A shot at point (5, 3) triggers the sensors (3,2) and (5,3), while shots at points (4,2) and
(5, 2) trigger sensors only at the endpoints. After shots at all other points, sensors (2,2), (3,2), (1,2), and (5,1) will trigger 2 times each, sensor (4,1) — 3 times, sensor (3,1) — 4 times, sensor (2,1) — 5 times, and the rest 1 time each. In total, all sensors will trigger 30 times.
During the tests, scientists fire the laser from the starting point ((A, B)) to every other point on the grid exactly once. Your task is to calculate the total number of times all sensors on the grid are triggered.
Input
The input consists of a single line with four integers, separated by spaces: (N), (M) ((2 N, M 1000000)), (A) ((1 A M)), and (B) ((1 B N)).
Output
The output should be a single integer representing the total number of times all sensors on the grid are triggered.