#include <bits/stdc++.h>
int main() {
  int p, q, l, r, i, j, k, k1, m, count = 0;
  scanf("%d %d %d %d", &p, &q, &l, &r);
  int arr[p][2], arr1[q][2];
  for (i = 0; i < p; i++)
    for (j = 0; j < 2; j++) scanf("%d", &arr[i][j]);
  for (i = 0; i < q; i++)
    for (j = 0; j < 2; j++) scanf("%d", &arr1[i][j]);
  int ans[r + 1];
  for (i = 0; i < r + 1; i++) ans[i] = 0;
  for (i = 0; i < q; i++) {
    for (j = 0; j < p; j++) {
      k = arr[j][0] - arr1[i][1];
      k1 = arr[j][1] - arr1[i][0];
      if (k < l) k = l;
      if (k1 > r) k1 = r + 1;
      for (m = k; m <= k1; m++) ans[m] = 1;
    }
  }
  for (i = 0; i < r + 1; i++)
    if (ans[i] == 1) count++;
  printf("%d\n", count);
  return 0;
}
