#include <bits/stdc++.h>
using namespace std;
vector<pair<int, int> > pr;
set<int> st;
bool Ok(int t) {
  for (int i = 0; i < pr.size(); ++i)
    for (int j = pr[i].first + t; j <= pr[i].second + t; ++j)
      if (st.find(j) != st.end()) return true;
  return false;
}
int main() {
  ios_base::sync_with_stdio(0);
  int p, q, l, r;
  cin >> p >> q >> l >> r;
  int x, y;
  pr.resize(q);
  for (int i = 0; i < p; ++i) {
    cin >> x >> y;
    for (int j = x; j <= y; ++j) st.insert(j);
  }
  for (int i = 0; i < q; ++i) {
    cin >> pr[i].first >> pr[i].second;
  }
  long long c = 0;
  for (int i = l; i <= r; ++i) {
    if (Ok(i)) ++c;
  }
  cout << c << endl;
  return 0;
}
