#include <bits/stdc++.h>
using namespace std;
int main() {
  int p, q, l, r, aps[50], ape[50], aqs[50], aqe[50], c = 0, s, e;
  bool x, a[1001];
  for (int i = 0; i < 1001; i++) a[i] = false;
  cin >> p >> q >> l >> r;
  for (int i = 0; i < p; i++) cin >> aps[i] >> ape[i];
  for (int i = 0; i < q; i++) cin >> aqs[i] >> aqe[i];
  for (int i = 0; i < q; i++)
    for (int j = 0; j < p; j++) {
      s = aps[j] - aqe[i];
      e = ape[j] - aqs[i];
      for (int k = s; k <= e; k++)
        if (k <= r && k >= l) a[k] = 1;
    }
  for (int i = l; i <= r; i++)
    if (a[i]) c++;
  cout << c;
}
