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