#include <bits/stdc++.h>
using namespace std;
const double PI = acos(-1);
const double eps = 1e-9;
const int inf = 2000000000;
const long long infLL = 9000000000000000000;
void faltu() { cerr << '\n'; }
template <typename T, typename... hello>
void faltu(T arg, const hello &...rest) {
  cerr << arg << ' ';
  faltu(rest...);
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  int p, q, l, r, a, b, c[2100], d[2100];
  bool t[2100];
  cin >> p >> q >> l >> r;
  for (int i = 1; i <= p; i++) {
    cin >> a >> b;
    for (int j = a; j <= b; j++) t[j] = 1;
  }
  for (int i = 1; i <= q; i++) cin >> c[i] >> d[i];
  int ans = 0;
  bool flag;
  for (int i = l; i <= r; i++) {
    flag = true;
    for (int j = 1; j <= q && flag == true; j++) {
      for (int k = c[j] + i; k <= d[j] + i; k++) {
        if (t[k] == 1) {
          flag = false;
          break;
        }
      }
    }
    if (flag == false) ans++;
  }
  cout << ans << '\n';
  return 0;
}
