#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;

int main(){
  ll r1, c1, r2, c2;
  cin >> r1 >> c1 >> r2 >> c2;

  auto ok = [&](ll a, ll b, ll c, ll d) {
    if (a == c && b == d) return 0;
    if (a + b == c + d || a - b == c - d || abs(a - c) + abs(b - d) <= 3) return 1;
    if ((a + b) % 2 == (c + d) % 2) return 2;

    for (ll i = c - 3; i <= c + 3; i++) {
      for (ll j = d - 3; j <= d + 3; j++) {
        if (abs(i - c) + abs(j - d) > 3) continue;
        if (i + j == a + b) return 2;
        if (i - j == a - b) return 2;
      }
    }
    return 3;
  };
  cout << ok(r1, c1, r2, c2) << endl;
  return 0;
}
#include <bits/stdc++.h>
#define rep(i,a,b) for(ll i=a,i##end=b;i<=i##end;i++)
#define drep(i,a,b) for(ll i=a,i##end=b;i>=i##end;i--)
typedef long long ll;
inline ll read() {
	ll x=0,f=1;char c=getchar();
	while(c<48||c>57){if(c=='-')f=-1;c=getchar();}
	while(c>=48&&c<=57)x=(x<<1)+(x<<3)+(c^48),c=getchar();
	return x*f;
}
using namespace std;
ll dp[1<<21];
int P[]={2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71};
int main() {
	ll l=read(),r=read();
	dp[0]=1;
	rep(i,l,r){
		int op=0;
		rep(j,0,19)
			if(i%P[j]==0)op|=(1<<j);
		drep(j,(1<<20)-1,0)
			if((j&op)==0)dp[j|op]+=dp[j];
	}
	ll ans=0;
	rep(i,0,(1<<20)-1)ans+=dp[i];
	printf("%lld\n",ans);
	return 0;
}