#include <bits/stdc++.h>
using namespace std;
long long int i, n, m, x, y, z, j, k, l, mn = LLONG_MAX, mx = 0, c, a[100005],
                                         r, s, cnt = 0, sum = 0;
string str;
void swap(int *xp, int *yp) {
  int temp = *xp;
  *xp = *yp;
  *yp = temp;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int p, q, l, r, l1, l2, r1, r2;
  cin >> p >> q >> l >> r;
  int i, j, k, a[p], b[p], c[q], d[q], e[1005];
  for (i = 0; i < p; i++) cin >> a[i] >> b[i];
  for (i = 0; i < q; i++) cin >> c[i] >> d[i];
  for (int t = l; t <= r; t++) {
    k = 0;
    for (j = 0; j < q; j++) {
      l1 = c[j] + t;
      r1 = d[j] + t;
      for (i = 0; i < p; i++) {
        l2 = a[i];
        r2 = b[i];
        if (r1 >= l2 && r2 >= l1) {
          cnt++;
          k = 1;
          break;
        }
      }
      if (k == 1) break;
    }
  }
  cout << cnt << "\n";
  return 0;
}
