#include <bits/stdc++.h>
using namespace std;
void boost() {
  std::ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
}
std::vector<long long> v;
void solve() {
  long long p, q, l, r;
  cin >> p >> q >> l >> r;
  vector<long long> make_pair(2002, 0);
  for (long long i = 0; i < p; i++) {
    long long x, y;
    cin >> x >> y;
    for (long long i = x; i < y + 1; i++) {
      make_pair[i]++;
    }
  }
  long long count = 0;
  long long chk[2002];
  long long c[55], d[55];
  for (long long i = 0; i < q; i++) {
    cin >> c[i] >> d[i];
  }
  memset(chk, 0, sizeof(chk));
  bool flag;
  for (long long i = l; i < r + 1; i++) {
    flag = false;
    for (long long j = 0; j < q; j++) {
      for (long long k = c[j] + i; k < d[j] + i + 1; k++) {
        if (make_pair[k]) {
          count++;
          flag = true;
          break;
        }
      }
      if (flag) {
        break;
      }
    }
  }
  cout << count << '\n';
}
int main() {
  boost();
  solve();
  return 0;
}
