#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:100000000000,100000000000")
using namespace std;
const double eps = 1E-9;
const double Exp = 2.718281828459045;
const double Pi = 3.1415926535897932;
const int NMAX = 50 + 5;
const int MMAX = 100000 + 5;
const int INF = 1000000000;
const int BASE = 1000000007;
template <typename T>
inline T abs(const T a) {
  if (a < 0) return -a;
  return a;
}
template <typename T>
inline T sqr(const T& a) {
  return a * a;
}
bool intersect(int a, int b, int c, int d) {
  if (a > c) {
    swap(a, c);
    swap(b, d);
  }
  if (b >= c) return 1;
  return 0;
}
int main() {
  ios::sync_with_stdio(false);
  int p, q, l, r;
  int i, j;
  cin >> p >> q >> l >> r;
  int a[NMAX];
  int b[NMAX];
  int c[NMAX];
  int d[NMAX];
  for (i = 1; i <= p; i++) cin >> a[i] >> b[i];
  for (i = 1; i <= q; i++) cin >> c[i] >> d[i];
  int k;
  int res = 0;
  int f;
  for (k = l; k <= r; k++) {
    f = 0;
    for (i = 1; i <= p; i++) {
      for (j = 1; j <= q; j++) {
        if (intersect(a[i], b[i], c[j] + k, d[j] + k)) f = 1;
      }
    }
    res += f;
  }
  cout << res << endl;
  return 0;
}
