#include <bits/stdc++.h>
using namespace std;
int main() {
  int p, q, l, r, a, b, t[3000], c[3000], d[3000], ans = 0;
  cin >> p >> q >> l >> r;
  for (int i = 0; i < 2010; ++i) t[i] = 0;
  for (int i = 0; i < p; ++i) {
    cin >> a >> b;
    for (int j = a; j <= b; ++j) t[j] = 1;
  }
  for (int i = 0; i < q; ++i) cin >> c[i] >> d[i];
  for (int i = l; i <= r; ++i) {
    bool flag = true;
    for (int j = 0; j < q && flag; ++j) {
      for (int k = c[j] + i; k <= d[j] + i; ++k)
        if (t[k]) {
          flag = false;
          break;
        }
    }
    if (!flag) ans++;
  }
  cout << ans << endl;
  return 0;
}
