#include <bits/stdc++.h>
using namespace std;
int main() {
  int p, q, l, r;
  cin >> p >> q >> l >> r;
  int a[p + 5], b[p + 5], c[q + 5], d[q + 5];
  for (int i = 0; i < p; i++) {
    cin >> a[i] >> b[i];
  }
  for (int i = 0; i < q; i++) {
    cin >> c[i] >> d[i];
  }
  bool taken = false;
  int num = 0;
  for (int i = l; i <= r; i++) {
    taken = false;
    for (int j = 0; j < p; j++)
      for (int k = 0; k < q; k++)
        if (!(c[k] + i > b[j] || d[k] + i < a[j])) taken = true;
    if (taken) num++;
  }
  cout << num << endl;
}
