#include <bits/stdc++.h>
using namespace std;
long long int primes[1000000];
long long int count_prime = 0;
long long int gl_i = 0;
int chck_prime(long long int n) {
  long long int t = sqrt(n);
  long long int i;
  int flg2 = 0;
  if (n == 2) return 1;
  for (i = 0; i < count_prime; i++) {
    if (n % primes[i] == 0) {
      return 0;
    }
    if (t < primes[i]) {
      return 1;
    }
  }
  return 1;
}
void gen_primes(long long int n) {
  primes[0] = 2;
  count_prime++;
  primes[1] = 3;
  count_prime++;
  for (long long int i = 3; i < n; i++) {
    {
      if (i % 2 == 0) {
        continue;
      }
      if (i % 3 == 0) {
        continue;
      }
      if (chck_prime(i) == 1) {
        primes[count_prime] = i;
        count_prime++;
      }
    }
  }
}
char s[200000 + 1][52];
char c[200000 + 1][52];
int tl[200000 + 1];
void combine(int p[], int mid, int l, int h) {
  int i = l;
  int j = mid + 1, k = l;
  while (i <= mid && j <= h) {
    if (strcmp(s[i], s[j]) < 0) {
      strcpy(c[k], s[i]);
      tl[k] = p[i];
      i++;
      k++;
    } else {
      strcpy(c[k], s[j]);
      tl[k] = p[j];
      j++;
      k++;
    }
  }
  while (i <= mid) {
    strcpy(c[k], s[i]);
    tl[k] = p[i];
    i++;
    k++;
  }
  while (j <= h) {
    strcpy(c[k], s[j]);
    tl[k] = p[j];
    j++;
    k++;
  }
  for (int i = l; i < k; i++) {
    strcpy(s[i], c[i]);
    p[i] = tl[i];
  }
}
void merge_sort(int p[], int l, int h) {
  if (h - l <= 1) {
    if (strcmp(s[l], s[h]) > 0) {
      char t[200000 + 1];
      strcpy(t, s[l]);
      strcpy(s[l], s[h]);
      strcpy(s[h], t);
      int tp = p[l];
      p[l] = p[h];
      p[h] = tp;
    }
    return;
  }
  int mid = (l + h) / 2;
  merge_sort(p, l, mid);
  merge_sort(p, mid + 1, h);
  combine(p, mid, l, h);
}
int main() {
  int p, q, l, r;
  scanf("%d %d %d %d", &p, &q, &l, &r);
  int x[2000], y[2000];
  memset(x, 0, sizeof(x));
  memset(y, 0, sizeof(y));
  for (int i = 0; i < p; i++) {
    int m1, m2;
    scanf("%d %d", &m1, &m2);
    for (int k = m1; k <= m2; k++) y[k]++;
  }
  for (int i = 0; i < q; i++) {
    int m1, m2;
    scanf("%d %d", &m1, &m2);
    for (int k = m1; k <= m2; k++) x[k]++;
  }
  int ans = 0;
  for (int k = l; k <= r; k++) {
    for (int i = 0; i <= 1000; i++) {
      if (i - k < 0) continue;
      if (x[i - k] >= 1 && y[i] >= 1) {
        ans++;
        break;
      }
    }
  }
  printf("%d\n", ans);
  return 0;
}
