#include <bits/stdc++.h>
using namespace std;
const int N = 2004;
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int p, q, l, r;
  cin >> p >> q >> l >> r;
  vector<pair<int, int>> f(p);
  for (auto &t : f) {
    cin >> t.first >> t.second;
  }
  vector<pair<int, int>> s(q);
  for (auto &t : s) {
    cin >> t.first >> t.second;
  }
  int ans = 0;
  for (int t = l; t <= r; t++) {
    vector<int> hv(N);
    for (auto [a, b] : f) {
      for (int i = a; i <= b; i++) {
        hv[i]++;
      }
    }
    int ok = 0;
    for (auto [a, b] : s) {
      for (int i = a + t; i <= b + t; i++) {
        if (hv[i]) ok = 1;
      }
    }
    ans += ok;
  }
  cout << ans << endl;
}
