#include <bits/stdc++.h>
using namespace std;
int main() {
  int jhanda = 0;
  long long int m, n, i, j, x, count = 0, t, p, q, l, r;
  long long int input[1010][2] = {0};
  long long int flag[10010] = {0};
  cin >> p >> q >> l >> r;
  i = 0;
  while (i < p) {
    cin >> m >> n;
    while (m <= n) {
      flag[m] = 1;
      m++;
    }
    i++;
  }
  for (i = 0; i < q; i++) cin >> input[i][0] >> input[i][1];
  i = l;
  while (i <= r) {
    jhanda = 0;
    j = 0;
    while (j < q) {
      m = input[j][0];
      while (m <= input[j][1]) {
        if (flag[m + i] == 1) {
          jhanda = 1;
          count++;
          break;
        }
        m++;
      }
      if (jhanda == 1) break;
      j++;
    }
    i++;
  }
  cout << count << endl;
  return 0;
}
