#include <bits/stdc++.h>
using namespace std;
template <class T>
bool Maximize(T &v, T nv) {
  if (nv > v) return v = nv, 1;
  return 0;
}
template <class T>
bool Minimize(T &v, T nv) {
  if (nv < v) return v = nv, 1;
  return 0;
}
template <class T>
T Mod(T &v, T mod) {
  return v = (v % mod + mod) % mod;
}
const long long INFLL = numeric_limits<long long>::max();
const long INF = numeric_limits<long>::max(), N = 51;
struct Seg {
  long l, r;
};
Seg a[N], b[N];
void solve() {
  long n, m, l, r;
  scanf("%ld %ld %ld %ld", &n, &m, &l, &r);
  for (long i = 0; i < n; ++i) scanf("%ld %ld", &a[i].l, &a[i].r);
  for (long i = 0; i < m; ++i) scanf("%ld %ld", &b[i].l, &b[i].r);
  long res = 0;
  for (long t = l; t <= r; ++t) {
    for (long i = 0; i < n; ++i) {
      for (long j = 0; j < m; ++j) {
        if (a[i].l <= b[j].r + t && a[i].r >= b[j].l + t) {
          res++;
          goto next;
        }
      }
    }
  next:;
  }
  printf("%ld\n", res);
}
void init() {}
int main() {
  init();
  solve();
  return 0;
}
