#include <bits/stdc++.h>
using namespace std;
int main() {
  int p, q, l, r;
  int Zb[50], Ze[50], Xb[50], Xe[50];
  int i, t, j, res = 0;
  cin >> p >> q >> l >> r;
  for (i = 0; i < p; i++) {
    cin >> Zb[i];
    cin >> Ze[i];
  }
  for (i = 0; i < q; i++) {
    cin >> Xb[i];
    cin >> Xe[i];
  }
  for (t = l; t <= r; t++) {
    i = j = 0;
    while (1) {
      if (Zb[i] > Xe[j] + t)
        j++;
      else if (Xb[j] + t > Ze[i])
        i++;
      else
        break;
      if (i == p || j == q) break;
    }
    if (i < p && j < q) {
      res += Ze[i] - Xb[j] - t + 1;
      t = Ze[i] - Xb[j];
    }
  }
  res -= t - (r + 1);
  cout << res << endl;
  return 0;
}
