#include <bits/stdc++.h>
using namespace std;
const long long BIG = 1e7;
pair<long long, long long> a[1000], b[1000], w;
long long x, y, q, p, l, r;
bool n;
int main() {
  cin >> p >> q >> l >> r;
  for (int i = 1; i <= p; i++) {
    cin >> x >> y;
    a[i] = {x, y};
  }
  for (int i = 1; i <= q; i++) {
    cin >> x >> y;
    b[i] = {x, y};
  }
  int cnt = 0;
  for (long long i = l; i <= r; i++) {
    n = 0;
    for (int j = 1; j <= q; j++) {
      w = {b[j].first + i, b[j].second + i};
      for (int k = 1; k <= p; k++) {
        if ((w.first <= a[k].second && w.first >= a[k].first) ||
            (w.second <= a[k].second && w.second >= a[k].first) ||
            w.first <= a[k].first && w.second >= a[k].second) {
          n = true;
          cnt++;
          break;
        }
      }
      if (n) break;
    }
  }
  cout << cnt;
  return 0;
}
