#include <bits/stdc++.h>
using namespace std;
const int maxn = 1005;
int time1[maxn], time2[maxn];
int main() {
  int p, q, l, r;
  cin >> p >> q >> l >> r;
  int a[p], b[p];
  int c[q], d[q];
  for (int i = 0; i < maxn; ++i) time2[i] = time1[i] = 0;
  for (int i = 0; i < p; ++i) {
    cin >> a[i] >> b[i];
    time1[a[i]] = 1;
    time1[b[i] + 1] = -1;
  }
  for (int i = 0; i < q; ++i) {
    cin >> c[i] >> d[i];
    time2[c[i]] = 1;
    time2[d[i] + 1] = -1;
  }
  for (int i = 0; i < maxn - 1; ++i) {
    time1[i + 1] += time1[i];
    time2[i + 1] += time2[i];
  }
  int ans = 0;
  for (int i = l; i <= r; ++i) {
    for (int j = 0; j + i < maxn - 1; ++j) {
      if (time2[j] != 0 && time1[i + j] != 0) {
        ++ans;
        break;
      }
    }
  }
  cout << ans << endl;
  return 0;
}
