#include <bits/stdc++.h>
using namespace std;
bool checker(vector<pair<int, int>> x, vector<pair<int, int>> z, int t) {
  for (int i = 0; i < (int)z.size(); i++) {
    for (int j = 0; j < (int)x.size(); j++) {
      int tempzf = z[i].first + t;
      int tempzs = z[i].second + t;
      if (tempzf <= x[j].second && x[j].first <= tempzs) return true;
    }
  }
  return false;
}
int main() {
  int p, q, l, r;
  cin >> p >> q >> l >> r;
  int cnt = 0;
  vector<pair<int, int>> xs(p);
  vector<pair<int, int>> zs(q);
  for (int i = 0; i < p; i++) cin >> xs[i].first >> xs[i].second;
  for (int i = 0; i < q; i++) cin >> zs[i].first >> zs[i].second;
  while (l <= r) {
    if (checker(xs, zs, l)) cnt++;
    l++;
  }
  cout << cnt << endl;
  return 0;
}
