#include <bits/stdc++.h>
using namespace std;
int p, q, l, r, ans = 0, i1, i2;
vector<pair<int, int> > pv, qv;
bool ok(int shift) {
  for (unsigned int i = 0; i < pv.size(); ++i) {
    for (unsigned int j = 0; j < qv.size(); ++j) {
      int locr = qv[j].second + shift;
      int locf = qv[j].first + shift;
      if ((locr >= pv[i].first && locr <= pv[i].second) ||
          (locf >= pv[i].first && locf <= pv[i].second) ||
          (locf <= pv[i].first && locr >= pv[i].second)) {
        return true;
      } else if (locf > pv[i].second) {
      }
    }
  }
  return false;
}
int main() {
  cin >> p >> q >> l >> r;
  for (int i = 0; i < p; ++i) {
    scanf("%d%d", &i1, &i2);
    pv.push_back(make_pair(i1, i2));
  }
  for (int i = 0; i < q; ++i) {
    scanf("%d%d", &i1, &i2);
    qv.push_back(make_pair(i1, i2));
  }
  for (int i = l; i <= r; ++i) {
    if (ok(i)) {
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}
