#include<algorithm>
#include<cstdio>
#include<cstring>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<iostream>
#include<string>
using namespace std;
int find_(int X, int x)
{
int sum = 0;
while(1)
{
if(X <= x)
return sum;
if(X & 1)
X++;
X /= 2;
sum++;
}
}
int main()
{
int W, H, w, h;
freopen("folding.in", "r", stdin);
freopen("folding.out", "w", stdout);
while(scanf("%d %d %d %d",&W, &H, &w, &h) != EOF)
{
if(W < H)
swap(W, H);
if(w < h)
swap(w,h);
if(W < w || H < h)
{
printf("-1\n");
continue;
}
int sum1 = find_(W, w);
int sum2 = find_(H, h);
int sum = sum1 + sum2;
sum1 = find_(W, h);
sum2 = find_(H, w);
sum = min(sum, sum1 + sum2);
cout << sum << endl;
}
return 0;
}