#include <bits/stdc++.h>
using namespace std;
int solve(int a, int b, int c, int d, int k) {
  if (a > b || c > d) return 0;
  if (k == 1) return 1;
  int res = max(min(b, d) - max(a, c) + 1, 0);
  int mid = (1 << k) - 1;
  mid = mid / 2 + 1;
  if (max({a, b, c, d}) < mid) return solve(a, b, c, d, k - 1);
  if (min({a, b, c, d}) > mid)
    return solve(a - mid, b - mid, c - mid, d - mid, k - 1);
  if (res > b - a || res > d - c) return res;
  if (a <= mid && b >= mid) {
    if (c <= mid && d >= mid) {
      res = max(res, solve(a, mid - 1, 1, d % mid, k - 1));
      res = max(res, solve(1, b % mid, c, mid - 1, k - 1));
    } else {
      res = max(res, solve(a, mid - 1, c % mid, d % mid, k - 1));
      res = max(res, solve(1, b % mid, c % mid, d % mid, k - 1));
    }
  } else if (c <= mid && d >= mid) {
    res = max(res, solve(a % mid, b % mid, c, mid - 1, k - 1));
    res = max(res, solve(a % mid, b % mid, 1, d % mid, k - 1));
  } else
    res = max(res, solve(a % mid, b % mid, c % mid, d % mid, k - 1));
  return res;
}
int main() {
  int a, b, c, d;
  scanf("%d %d %d %d", &a, &b, &c, &d);
  printf("%d", solve(a, b, c, d, 30));
  return 0;
}
