#include <bits/stdc++.h>
using namespace std;
const int INF = (int)1e9;
const long long INF64 = (long long)1e18;
const long double eps = 1e-9;
const long double pi = 3.14159265358979323846;
bool check(int a, int b, int c, int d) {
  if ((b < c) || (a > d)) {
    return false;
  }
  return true;
}
int main() {
  int p, q, l, r, a, b, ans = 0;
  cin >> p >> q >> l >> r;
  vector<pair<int, int> > p_values;
  vector<pair<int, int> > q_values;
  for (int i = 0; i < p; i++) {
    cin >> a >> b;
    pair<int, int> pr = make_pair(a, b);
    p_values.push_back(pr);
  }
  for (int i = 0; i < q; i++) {
    cin >> a >> b;
    pair<int, int> pr = make_pair(a, b);
    q_values.push_back(pr);
  }
  for (int t = l; t <= r; t++) {
    bool ch = false;
    for (int i = 0; i < q_values.size(); i++) {
      pair<int, int> pr = q_values[i];
      int st = pr.first + t, end = pr.second + t;
      for (int j = 0; j < p_values.size(); j++) {
        if (check(st, end, p_values[j].first, p_values[j].second)) {
          ans++;
          ch = true;
          break;
        }
      }
      if (ch) {
        break;
      }
    }
  }
  cout << ans << endl;
  return 0;
}
