#include <bits/stdc++.h>
using namespace std;
const long long mod = 1000 * 1000 * 1000 + 7;
const long long MAX = 600005;
set<pair<int, int> > segs1, segs2;
int ans = 0;
int inter(pair<int, int> p1, pair<int, int> p2) {
  return min(p1.second, p2.second) - max(p1.first, p2.first) + 1;
}
void get() {
  for (auto seg1 : segs1)
    for (auto seg2 : segs2) ans = max(ans, inter(seg1, seg2));
}
void trans(set<pair<int, int> > &s, int d) {
  set<pair<int, int> > res;
  for (auto seg : s) {
    if (seg.first > d) {
      res.insert({seg.first - d, seg.second - d});
    } else if (seg.second < d) {
      res.insert(seg);
    } else {
      if (seg.first <= d - 1) res.insert({seg.first, d - 1});
      if (seg.second >= d + 1) res.insert({1, seg.second - d});
    }
  }
  s = res;
}
int main() {
  ios_base::sync_with_stdio(0);
  int l1, r1, l2, r2;
  cin >> l1 >> r1 >> l2 >> r2;
  segs1.insert({l1, r1});
  segs2.insert({l2, r2});
  get();
  for (int i = 30; i >= 0; i--) {
    trans(segs1, (1 << i));
    trans(segs2, (1 << i));
    get();
  }
  cout << ans;
}
