#include <bits/stdc++.h>
using namespace std;
int main() {
  int p, q, l, r, *a, *b, *c, *d, kol = 0, h = 0;
  cin >> p;
  a = new int[p];
  b = new int[p];
  cin >> q;
  c = new int[q];
  d = new int[q];
  cin >> 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];
  for (int i = l; i <= r; i++) {
    if (kol) {
      h++;
      kol = 0;
    }
    for (int j = 0; j < q; j++)
      for (int k = 0; k < p; k++) {
        if (c[j] + i < a[k]) {
          if (d[j] + i < a[k]) continue;
          kol++;
        } else {
          if (c[j] + i > b[k]) continue;
          kol++;
        }
      }
    if (kol) {
      h++;
      kol = 0;
    }
  }
  cout << h;
  return 0;
}
