#include <bits/stdc++.h>
using namespace std;
int main() {
  int p, q, l, r;
  cin >> p >> q >> l >> r;
  pair<int, int> a[p + 1];
  pair<int, int> b[q + 1];
  for (int i = 0; i < p; i++) {
    int temp1, temp2;
    cin >> temp1 >> temp2;
    a[i] = make_pair(temp1, temp2);
  }
  for (int i = 0; i < q; i++) {
    int temp1, temp2;
    cin >> temp1 >> temp2;
    b[i] = make_pair(temp1, temp2);
  }
  int cont = 0;
  while (l <= r) {
    for (int i = 0; i < p; i++) {
      int t = 0;
      for (int j = 0; j < q; j++) {
        if ((a[i].first >= b[j].first + l && a[i].first <= b[j].second + l) ||
            (a[i].second >= b[j].first + l && a[i].second <= b[j].second + l) ||
            (b[j].first + l >= a[i].first && b[j].first + l <= a[i].second) ||
            (b[j].second + l >= a[i].first && b[j].second + l <= a[i].second)) {
          cont++;
          t = 1;
          break;
        }
      }
      if (t == 1) break;
    }
    l++;
  }
  cout << cont << endl;
  return 0;
}
