#include <bits/stdc++.h>
using namespace std;
vector<pair<int, int> > a, b;
vector<pair<int, int> > go(vector<pair<int, int> > a, int k) {
  vector<pair<int, int> > res;
  for (int i = (0); i < (a.size()); ++i) {
    int v = a[i].first % k;
    int lv;
    int last;
    if (v == 0) {
      lv = a[i].first;
      last = lv + 1;
    } else {
      last = a[i].first;
      lv = last - v;
    }
    while ((res.size() <= 3) && (last <= a[i].second)) {
      res.push_back(make_pair(
          last - lv,
          ((a[i].second + 1 < lv + k) ? (a[i].second + 1) : (lv + k)) - lv -
              1));
      lv += k;
      last = lv + 1;
    }
    if (res.size() >= 3) break;
  }
  if (res.size() >= 3) {
    res[0] = res[1];
    res.pop_back();
    res.pop_back();
  }
  return res;
}
int solve(int l1, int r1, int l2, int r2) {
  a.push_back(make_pair(l1, r1));
  b.push_back(make_pair(l2, r2));
  int res = 0;
  for (int k1 = 30; k1 > 0; --k1) {
    int k = (1 << (k1 - 1));
    for (int i = (0); i < (a.size()); ++i)
      for (int j = (0); j < (b.size()); ++j) {
        int v1 = a[i].first % k;
        int v2 = b[j].first % k;
        int f1 = a[i].first;
        if (v1) f1 += k - v1;
        int f2 = b[j].first;
        if (v2) f2 += k - v2;
        if ((f1 <= a[i].second) && (f2 <= b[j].second)) {
          int left = ((a[i].first < b[j].first) ? (b[j].first) : (a[i].first));
          int right =
              ((a[i].second < b[j].second) ? (a[i].second) : (b[j].second));
          res = ((res < right - left + 1) ? (right - left + 1) : (res));
        }
      }
    a = go(a, k);
    b = go(b, k);
  }
  return res;
}
string get(int k) {
  string res = "a";
  for (int i = (1); i < (k); ++i) {
    string s = " ";
    s[0] = 'a' + i;
    res = res + s + res;
  }
  return res;
}
int brut(int l1, int r1, int l2, int r2, int k) {
  string s = get(k);
  int res = 0;
  l1--;
  r1--;
  l2--;
  r2--;
  for (int i = (l1); i < (r1 + 1); ++i)
    for (int len = (1); len < (r1 - l1 + 2); ++len) {
      if (i + len - 1 > r1) continue;
      for (int j = l2; j + len - 1 <= r2; ++j) {
        string s1 = s.substr(i, len);
        string s2 = s.substr(j, len);
        if (s1 == s2) res = max(res, len);
      }
    }
  return res;
}
int main() {
  int l1, r1, l2, r2;
  cin >> l1 >> r1 >> l2 >> r2;
  int res = solve(l1, r1, l2, r2);
  cout << res << endl;
  return 0;
  for (int it = (0); it < (100); ++it) {
    int k = 7;
    int l1 = rand() % ((1 << k) - 1) + 1;
    int r1 = rand() % ((1 << k) - 1) + 1;
    int l2 = rand() % ((1 << k) - 1) + 1;
    int r2 = rand() % ((1 << k) - 1) + 1;
    if (l1 > r1) swap(l1, r1);
    if (l2 > r2) swap(l2, r2);
    int res1 = brut(l1, r1, l2, r2, k);
    int res2 = solve(l1, r1, l2, r2);
    if (res1 == res2)
      printf("ok");
    else {
      printf("FAIL!!! %d %d %d %d\n", l1, r1, l2, r2);
      return 0;
    }
  }
  return 0;
}
