#include <bits/stdc++.h>
using namespace std;
int main() {
  int p, q, l, r;
  cin >> p >> q >> l >> r;
  vector<bool> z(1001, false);
  vector<int> c(q), d(q);
  for (int i = (0); i < (p); ++i) {
    int a, b;
    cin >> a >> b;
    for (int j = (a); j < (b + 1); ++j) z[j] = true;
  }
  for (int i = (0); i < (q); ++i) cin >> c[i] >> d[i];
  int res = 0;
  for (int i = (l); i < (r + 1); ++i) {
    auto func = [&]() {
      for (int j = (0); j < (q); ++j)
        for (int k = (min(i + c[j], 1000)); k < (min(i + d[j], 1000) + 1); ++k)
          if (z[k]) return true;
      return false;
    };
    if (func()) res++;
  }
  cout << res;
}
