eolymp
bolt
Try our new interface for solving problems
Problems

Folding

Folding

As you can remember, Alex is fond of origami. She switched from squares to rectangles, and rectangles are much more difficult to master. Her main interest is to determine what is the minimum possible number of folds required to transform W * H rectangle to w * h one. The result of each fold should also be rectangular, so it is only allowed to make folds that are parallel to the sides of the rectangle. Help Alex and write a program that determines the minimum required number of folds.

Input

The first line contains two integers W and H - the initial rectangle dimensions. The second line contains two more integers w and h - the target rectangle dimensions (1W, H, w, h109).

Output

Output a single integer - the minimum required number of folds to transform the initial rectangle to the target one.

If the required transformation is not possible, output -1.

Explanation

In the first example you should fold 2 * 7 rectangle to 2 * 4, and then to 2 * 2.

In the second example you should fold 10 * 6 rectangle to 10 * 4, then to 8 * 4, and rotate it to 4 * 8.

In the third example it is impossible to fold 5 * 5 rectangle to 1 * 6 one (remember that folds must be parallel to the rectangle sides).

Time limit 1 second
Memory limit 128 MiB
Input example #1
2 7
2 2
Output example #1
2
Input example #2
10 6
4 8
Output example #2
2
Input example #3
5 5
1 6
Output example #3
-1
Source 2016 ACM NEERC, Northern subregion, October 22, Problem F