#include <bits/stdc++.h>
using namespace std;
void solve();
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int t = 1;
  while (t--) {
    solve();
    cout << "\n";
  }
  return 0;
}
void solve() {
  int p, q, l, r;
  int a, b, c, d;
  cin >> p >> q >> l >> r;
  vector<pair<int, int>> ab;
  vector<pair<int, int>> cd;
  set<int> lr;
  for (int i = 0; i < p; ++i) {
    cin >> a >> b;
    ab.push_back(make_pair(a, b));
  }
  for (int i = 0; i < q; ++i) {
    cin >> c >> d;
    cd.push_back(make_pair(c, d));
  }
  int count = 0;
  for (int k = l; k < r + 1; ++k) {
    bool flag = 0;
    for (auto j : ab) {
      for (auto i : cd) {
        if (max(i.second + k, j.second) - min(i.first + k, j.first) <=
            (i.second - i.first + j.second - j.first))
          flag = 1;
        if (flag) break;
      }
      if (flag) break;
    }
    if (flag) count++;
  }
  cout << count;
  return;
}
