#include <bits/stdc++.h>
using namespace std;
int p, q, l, r;
int a[50 + 10], b[50 + 10], c[50 + 10], d[50 + 10];
int main(void) {
  cin >> p >> q >> l >> r;
  for (int i = 0; i < p; ++i) {
    cin >> a[i] >> b[i];
  }
  for (int i = 0; i < q; ++i) {
    cin >> c[i] >> d[i];
  }
  int cnt = 0;
  for (int t = l; t <= r; ++t) {
    bool ok = false;
    for (int i = 0; i < p; ++i) {
      for (int j = 0; j < q; ++j) {
        int cc = c[j] + t, dd = d[j] + t;
        if (cc > b[i] || dd < a[i])
          continue;
        else {
          ok = true;
          ++cnt;
          break;
        }
      }
      if (ok) break;
    }
  }
  cout << cnt << endl;
  return 0;
}
