#include <bits/stdc++.h>
using namespace std;
class TaskB {
 public:
  void solve(std::istream& in, std::ostream& out) {
    int p, q, l, r;
    in >> p >> q >> l >> r;
    vector<bool> Z(2005, false);
    for (int i = 0; i < p; i++) {
      int a, b;
      in >> a >> b;
      for (int j = a; j <= b; j++) Z[j] = true;
    }
    vector<bool> X(2005, false);
    for (int i = 0; i < q; i++) {
      int a, b;
      in >> a >> b;
      for (int j = a + l; j <= b + l; j++) X[j] = true;
    }
    int res = 0;
    for (int i = 0; i < r - l + 1; i++) {
      for (int j = 0; j < 2005; j++) {
        if (X[j] == true and Z[j] == true) {
          res++;
          break;
        }
      }
      X.insert(X.begin(), false);
    }
    out << res;
  }
};
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  TaskB solver;
  std::istream& in(std::cin);
  std::ostream& out(std::cout);
  solver.solve(in, out);
  return 0;
}
