logo AlgoBeat OnlineJudge
登录 注册

#206194. [NWRRC 2016] Folding

内存限制:256 MiB 时间限制:2000 ms 标准输入输出
题目类型:VJudge(洛谷) 评测方式:VJudge
上传者: 匿名

题目描述

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 rectangle to 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.

输入格式

The first line of the input contains two integers and -- the initial rectangle dimensions. The second line contains two more integers and -- the target rectangle dimensions

输出格式

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

2 7
2 2

样例输出 1

2

样例输入 2

10 6
4 8

样例输出 2

2

样例输入 3

5 5
1 6

样例输出 3

-1

数据范围与提示

Time limit: 2 s, Memory limit: 256 MB.