#include <bits/stdc++.h>
using namespace std;
long long l1, r1, l2, r2, ans = 0;
int m1, m2;
void solve(long long &l, long long &r, int &m) {
  int x = 0;
  long long cx = 1;
  while (cx <= r) {
    cx *= 2;
    x++;
  }
  cx /= 2;
  if (cx >= l) {
    m = x - 1;
    l = cx - l;
    r = r - cx;
    return;
  } else {
    l = l - cx;
    r = r - cx;
    solve(l, r, m);
    return;
  }
}
long long check(const long long &l, const long long &r) {
  if (l == 0 || r == 0) return 0;
  int lx = 0, rx = 0;
  long long cl = 1, cr = 1;
  while (cl <= l) {
    cl *= 2;
    lx++;
  }
  while (cr <= r) {
    cr *= 2;
    rx++;
  }
  if (lx != rx) return (min(l, r));
  cl /= 2;
  long long v = max(cl - 1, l - cl + 1 + r - cl);
  return v;
}
int main() {
  cin >> l1 >> r1 >> l2 >> r2;
  solve(l1, r1, m1);
  solve(l2, r2, m2);
  if (m1 > m2) {
    swap(l1, l2);
    swap(r1, r2);
    swap(m1, m2);
  }
  if (m1 == m2) {
    ans = min(l1, l2) + 1 + min(r1, r2);
    ans = max(ans, max(check(l1, r2), check(l2, r1)));
  } else {
    ans = max(min(l1, l2), min(r1, r2));
    ans = max(ans, max(check(l1, r2), check(l2, r1)));
    long long v = (1ll << m1);
    if (l2 >= v) ans = max(ans, min(l2 - v, l1) + 1 + r1);
    if (r2 >= v) ans = max(ans, l1 + 1 + min(r2 - v, r1));
  }
  cout << ans << endl;
  return 0;
}
