#include <bits/stdc++.h>
using namespace std;
int main() {
  int p, q, l, r;
  int ans = 0;
  cin >> p >> q >> l >> r;
  bool qq = false;
  vector<int> a(p), b(p), c(q), d(q);
  for (int i = 0; i <= p - 1; i++) cin >> a[i] >> b[i];
  for (int i = 0; i <= q - 1; i++) cin >> c[i] >> d[i];
  for (int k = l; k <= r; k++) {
    for (int i = 0; i <= q - 1; i++) {
      for (int j = 0; j <= p - 1; j++) {
        if (c[i] + k >= a[j] && c[i] + k <= b[j]) {
          qq = true;
          break;
        } else {
          if (d[i] + k >= a[j] && d[i] + k <= b[j]) {
            qq = true;
            break;
          }
        }
        if (c[i] + k <= a[j] && d[i] + k >= b[j]) {
          qq = true;
          break;
        }
      }
      if (qq) {
        ++ans;
        qq = false;
        break;
      }
    }
  }
  cout << ans << '\n';
  return 0;
}
