XTL's Chessboard(Continuation)
时间限制:C/C++/Rust/Pascal 1秒,其他语言2秒
空间限制:C/C++/Rust/Pascal 256 M,其他语言512 M
64bit IO Format: %lld

题目描述

Since last time, Zjx was able to give the answer in a flash with your help, Xutianli learned from the bitter experience and went to acquire a chessboard factory, which can manufacture any type of chessboard at any time.

XTL explained to Zjx that he was training in "quantum artificial intelligence". That is, when Zjx did not observe, XTL was in the superposition state of artificially training his own intelligence and fishing for fish. Once Zjx is observed, XTL will be in touching fish mode. (touching fish means dereliction of duty)

Since Zjx found out that his observation would lead to dereliction, the more he thought about it, the more ashamed he felt, and decided to visit XTL's house to apologize.
After a friendly correspondence, XTL took out a ball and asked Zjx to play a new game.
Prescribed procedure is as follows.

On the rectangular chessboard composed of squares of X * Y, select a left or bottom grid as the starting grid, and then place a ball in the center of the grid. The diameter of the ball is the length of the side of a grid on the chessboard. Push the ball up 45 degrees to make it roll on the chessboard. When the ball touches the edge of the board, it will bounce back. The rebound rule is: the rebounding route is perpendicular to the original route, just as the reflection of light on a plane mirror. If the ball attaches the corner, it will roll back according to the original route. The ball moves on the chessboard from the starting grid (if the starting grid is in the upper left or lower right corner, it will rebound immediately at the beginning) until it returns to the starting grid.

XTL will use the chessboard factory to make a random chessboard, place the ball, and kick it obliquely up 45 degrees to let Zjx count the number of grids the ball has passed through for odd number of times and tell XTL the answer after the ball stops moving.

Last time you helped zjx, so zjx had sluggishness, and asks you to help him find out the answer. His paper has reached a critical moment, and Zjx had contacted several SCI journals in the Mariana Trench.

Smart as you, can you tell him the solution of this extremely depressing game?

输入描述:

The input consists of a single test case specified with two lines. The first line contains four integers x, y, a and b, where x is the length of the chessboard, y is the width of chessboard, (a, b) is the coordinate of the starting grids.(x,y>=2,x*y<=1000000000)

输出描述:

The output consists of a single integer, representing the number of grids the ball has passed through for odd number of times.
示例1

输入

复制
10 7 1 5

输出

复制
22