#P3475. Paper-, er, Transcript-Folding Game

Paper-, er, Transcript-Folding Game

Description

Most recently, frkstyc has engaged himself busily in applying for admission to graduate schools abroad. Among all those tasks he has to complete, one is to prepare the transcripts to mail to the admission offices. Earlier, frkstyc ordered his transcripts from the university’s Educational Admnistration Division (EAD). As per the regulations of the EAD, upon claiming the transcripts in the EAD office, he had to fold the transcripts until they fit into the envelops provided by the EAD, which were later sealed and stamped at the scene. Having unwisely overestimated the actual number of transcripts required, he ordered twice as many transcripts as needed, which left him with a very uninteresting and fatiguing paper-folding game. Finishing the work, he swore to himself that never again would he trouble himself with applications for admission aboard.

To help you better understand frkstyc’s experience folding his transcripts, consider this problem: given the dimensions of an envelop and a transcript, how many times does the transcript have to be folded until its dimensions do not exceed those of the envelop? Remember that frkstyc was preparing the transcripts for the review of faculty members in admission commitees, which required him to fold the transcripts either horizontally or vertically each time, halving its size. Additionally, the transcript must not lie slanted in the envelop.

Input

The input contains multiple test cases each occupying one line. Each test case consists of four integers a, b, c, d (0 < a, b, c, d ≤ 231 − 1) indicating that the dimension of an envelop is a × b and that of a transcript is c × d. Process until EOF is met.

Output

For each test case, output the minimum number of times a transcript has to be folded.

1 2 1 4
2 1 1 4
1
1

Source

POJ Founder Monthly Contest – 2007.12.30

, frkstyc