#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int p, q, l, r, c = 0, g;
  cin >> p >> q >> l >> r;
  pair<long long int, long long int> a[p], b[q];
  for (long long int i = 0; i < p; i++) cin >> a[i].first >> a[i].second;
  for (long long int i = 0; i < q; i++) cin >> b[i].first >> b[i].second;
  for (long long int i = l; i <= r; i++) {
    for (long long int j = 0, g = 0; j < p && !g; j++) {
      for (long long int k = 0; k < q && !g; k++) {
        if (b[k].second + i >= a[j].first && b[k].first + i <= a[j].second)
          g = ++c;
      }
    }
  }
  cout << c << "\n";
  return 0;
}
