#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int p, q, l, r;
  cin >> p;
  cin >> q;
  cin >> l;
  cin >> r;
  vector<vector<int> > tab1(p), tab2(q);
  for (int i = 0; i < p; i++) tab1[i].resize(2);
  for (int i = 0; i < q; i++) tab2[i].resize(2);
  int a, b;
  for (int i = 0; i < p; i++) {
    cin >> a;
    cin >> b;
    tab1[i][0] = a;
    tab1[i][1] = b;
  }
  for (int i = 0; i < q; i++) {
    cin >> a;
    cin >> b;
    tab2[i][0] = a;
    tab2[i][1] = b;
  }
  int nb = 0;
  for (int i(l); i <= r; i++) {
    for (int ii(0); ii < q; ii++) {
      for (int j(0); j < p; j++) {
        if (tab1[j][0] <= (tab2[ii][0] + i) &&
            (i + tab2[ii][0]) <= tab1[j][1]) {
          nb++;
          goto next;
        }
        if (tab1[j][0] <= (tab2[ii][1] + i) &&
            (i + tab2[ii][1]) <= tab1[j][1]) {
          nb++;
          goto next;
        }
        if ((i + tab2[ii][0]) <= tab1[j][0] &&
            tab1[j][1] <= (i + tab2[ii][1])) {
          nb++;
          goto next;
        }
      }
    }
  next:;
  }
  cout << nb << endl;
  return 0;
}
