#include <bits/stdc++.h>
using namespace std;
vector<pair<int, int> > lz;
vector<pair<int, int> > lx;
int main() {
  int p, q, l, r;
  cin >> p >> q >> l >> r;
  for (int i = 0; i < p; i++) {
    int a, b;
    cin >> a >> b;
    lz.push_back(make_pair(a, b));
  }
  for (int i = 0; i < q; i++) {
    int a, b;
    cin >> a >> b;
    lx.push_back(make_pair(a, b));
  }
  int k = 0;
  for (int t = l; t <= r; t++) {
    int y = 0;
    for (unsigned int i = 0; i < lx.size(); i++) {
      for (unsigned int j = 0; j < lz.size(); j++) {
        if ((lx[i].first + t <= lz[j].second &&
             lx[i].first + t >= lz[j].first) ||
            (lx[i].second + t <= lz[j].second &&
             lx[i].second + t >= lz[j].first)) {
          y++;
        }
        if ((lz[j].first >= lx[i].first + t &&
             lz[j].first <= lx[i].second + t) ||
            (lz[j].second >= lx[i].first + t &&
             lz[j].second <= lx[i].second + t)) {
          y++;
        }
      }
    }
    if (y > 0) k++;
  }
  cout << k << endl;
  return 0;
}
