#include <bits/stdc++.h>
using namespace std;
const int N = 1100;
int n, m, t, k;
int a[N], b[N];
signed main() {
  int p, q, l, r;
  int x, y;
  cin >> p >> q >> l >> r;
  while (p--) {
    cin >> x >> y;
    for (int i = x; i <= y; i++) {
      a[i] = 1;
    }
  }
  while (q--) {
    cin >> x >> y;
    for (int i = x; i <= y; i++) {
      b[i] = 1;
    }
  }
  m = 0;
  for (t = l; t <= r; t++) {
    for (int i = t; i <= 1000; i++) {
      if (b[i - t] == 1 && a[i] == 1) {
        m++;
        break;
      }
    }
  }
  cout << m << endl;
  return 0;
}
