#include <bits/stdc++.h>
using namespace std;
int solve(int l1, int r1, int l2, int r2, int k);
int main() {
  int l1, r1, l2, r2;
  int k = 30;
  while (scanf("%d %d %d %d", &l1, &r1, &l2, &r2) != EOF) {
    int res = solve(l1, r1, l2, r2, k);
    printf("%d\n", res);
  }
  return 0;
}
int solve(int l1, int r1, int l2, int r2, int k) {
  if (l1 > l2 || (l1 == l2 && r1 < r2)) {
    return solve(l2, r2, l1, r1, k);
  }
  if (l1 > r1 || l2 > r2 || k == 0) {
    return 0;
  }
  if (r1 >= r2) {
    return (r2 - l2 + 1);
  }
  int mid = (1 << (k - 1));
  if (l1 > mid) {
    return solve(l1 - mid, r1 - mid, l2 - mid, r2 - mid, k - 1);
  }
  if (l2 > mid) {
    return solve(l1, r1, l2 - mid, r2 - mid, k);
  }
  if (r1 < mid && r2 < mid) {
    return solve(l1, r1, l2, r2, k - 1);
  }
  int res[5];
  res[0] = max(r1 - l2 + 1, 0);
  res[1] = solve(l1, min(r1, mid - 1), l2, mid - 1, k);
  res[2] = solve(l1, min(r1, mid - 1), 1, r2 - mid, k);
  res[3] = solve(mid + 1, r1, l2, mid - 1, k);
  res[4] = solve(mid + 1, r1, mid + 1, r2, k);
  return *max_element(res, res + 5);
}
