#include <bits/stdc++.h>
#include<string.h>
#include<math.h>
using namespace std;
typedef long long int ll;

int main(){
	ios_base::sync_with_stdio(false); cin.tie(0);
	ll x,y,a,b;
    cin>>x>>y>>a>>b;
    ll cnt=0;
    while(x<=(b-1)/a && x*a<y)
    {
        x*=a;
        cnt++;
    }
    cnt+=(y-x-1)/b;
    cout<<cnt<<endl;
    return 0;
}
#include <bits/stdc++.h>
using namespace std;

int main() {
    int r1, c1, r2, c2;
    cin >> r1 >> c1 >> r2 >> c2;
    int r = r1 - r2, c = c1 - c2;
    int ans = 3;
    if(!r && !c) ans = 0;
    else if(r == c || r == -c || abs(r) + abs(c) <= 3) ans = 1;
    else if((r ^ c ^ 1) & 1 || abs(r) + abs(c) <= 6 || abs(r + c) <= 3 || abs(r - c) <= 3) ans = 2;
    cout << ans << endl;    
}