#include <bits/stdc++.h>
using namespace std;
int l1, r1, l2, r2, ans;
int min(int a, int b) { return a < b ? a : b; }
int max(int a, int b) { return a > b ? a : b; }
int check(int a) {
  if (a > ans) ans = a;
  return a;
}
int solve(int l1, int r1, int l2, int r2, int k) {
  if (l1 == l2 && r1 == r2) {
    if (r1 - l1 + 1 > ans) ans = r1 - l1 + 1;
    return r1 - l1 + 1;
  }
  if (r1 - l1 + 1 <= ans || r2 - l2 + 1 <= ans) return 0;
  if (k == 0) return 0;
  int mid = (1 << k);
  if (r1 < mid && r2 < mid) return check(solve(l1, r1, l2, r2, k - 1));
  if (l1 > mid && l2 > mid)
    return check(solve(l1 - mid, r1 - mid, l2 - mid, r2 - mid, k - 1));
  if (r1 < mid && l2 > mid)
    return check(solve(l1, r1, l2 - mid, r2 - mid, k - 1));
  if (r2 < mid && l1 > mid)
    return check(solve(l1 - mid, r1 - mid, l2, r2, k - 1));
  if (l1 <= mid && r1 >= mid) {
    if (r2 < mid)
      return check(max(solve(l1, mid - 1, l2, r2, k - 1),
                       solve(1, r1 - mid, l2, r2, k - 1)));
    if (l2 > mid)
      return check(max(solve(l1, mid - 1, l2 - mid, r2 - mid, k - 1),
                       solve(1, r1 - mid, l2 - mid, r2 - mid, k - 1)));
    int ret = min(r1, r2) - max(l1, l2) + 1;
    ret = max(ret, solve(l1, mid - 1, 1, r2 - mid, k - 1));
    ret = max(ret, solve(1, r1 - mid, l2, mid - 1, k - 1));
    return check(ret);
  }
  if (l2 <= mid && r2 >= mid) {
    if (r1 < mid)
      return check(max(solve(l1, r1, l2, mid - 1, k - 1),
                       solve(l1, r1, 1, r2 - mid, k - 1)));
    if (l1 > mid)
      return check(max(solve(l1 - mid, r1 - mid, l2, mid - 1, k - 1),
                       solve(l1 - mid, r1 - mid, 1, r2 - mid, k - 1)));
    int ret = min(r1, r2) - max(l1, l2) + 1;
    ret = max(ret, solve(l1, mid - 1, 1, r2 - mid, k - 1));
    ret = max(ret, solve(1, r1 - mid, l2, mid - 1, k - 1));
    return check(ret);
  }
}
int main() {
  cin >> l1 >> r1 >> l2 >> r2;
  cout << solve(l1, r1, l2, r2, 29) << endl;
  return 0;
}
