#include <bits/stdc++.h>
using namespace std;
int getint() {
  unsigned int c;
  int x = 0;
  while (((c = getchar()) - '0') >= 10) {
    if (c == '-') return -getint();
    if (!~c) exit(0);
  }
  do {
    x = (x << 3) + (x << 1) + (c - '0');
  } while (((c = getchar()) - '0') < 10);
  return x;
}
set<pair<int, int> > range[33], r1[33], r2[33];
void solve(int srt, int end, int depth) {
  int len = (1 << depth) - 1, midpos = len / 2;
  int nsrt = srt, nend = end;
  if (depth > 1) {
    if (end <= midpos) {
      if (end == midpos) end--;
      solve(srt, end, depth - 1);
    } else if (srt >= midpos) {
      if (srt == midpos) srt++;
      solve(srt - midpos - 1, end - midpos - 1, depth - 1);
    } else {
      int s1 = srt, e1 = midpos - 1;
      int s2 = 0, e2 = end - midpos - 1;
      if (s1 <= s2 and e2 <= e1) {
        solve(s1, e1, depth - 1);
      } else if (s2 <= s1 and e1 <= e2) {
        solve(s2, e2, depth - 1);
      } else {
        solve(s1, e1, depth - 1);
        solve(s2, e2, depth - 1);
      }
    }
  }
  srt = nsrt, end = nend;
  set<pair<int, int> > st;
  set<pair<int, int> >::iterator it;
  bool add = 1;
  for (it = range[depth].begin(); it != range[depth].end(); it++) {
    if (it->first <= srt and end <= it->second) {
      st.insert(*it);
      add = 0;
      continue;
    }
    if (srt <= it->first and it->second <= end) {
      continue;
    }
    st.insert(*it);
  }
  if (add) st.insert(make_pair(srt, end));
  range[depth].swap(st);
}
int main() {
  int i, j, tcc, tc = 1 << 28, a, b;
  set<pair<int, int> >::iterator it, jt, kt;
  for (tcc = 0; tcc < tc; tcc++) {
    a = getint() - 1, b = getint() - 1;
    for (i = 0; i < 31; i++) range[i].clear();
    solve(a, b, 30);
    for (i = 0; i < 31; i++) r1[i].swap(range[i]);
    a = getint() - 1, b = getint() - 1;
    for (i = 0; i < 31; i++) range[i].clear();
    solve(a, b, 30);
    for (i = 0; i < 31; i++) r2[i].swap(range[i]);
    int res = 0;
    for (i = 1; i < 31; i++) {
      for (it = r1[i].begin(); it != r1[i].end(); it++) {
        for (jt = r2[i].begin(); jt != r2[i].end(); jt++) {
          int s = max(it->first, jt->first);
          int t = min(it->second, jt->second);
          if (s > t) continue;
          res = max(res, t - s + 1);
        }
      }
    }
    printf("%d\n", res);
  }
  return 0;
}
