#include <bits/stdc++.h>
int freq[1005] = {0};
int find_int(int a, int b, int c, int d) {
  int i;
  if (b < c) return 0;
  if (a > d) return 0;
  if (a <= c && b >= d) {
    for (i = c; i <= d; i++) freq[i] = 1;
    return d - c + 1;
  } else if (a >= c && b <= d) {
    for (i = a; i <= b; i++) freq[i] = 1;
    return b - a + 1;
  } else if (a >= c && b >= d) {
    for (i = a; i <= d; i++) freq[i] = 1;
    return d - a + 1;
  } else if (a <= c && b <= d) {
    for (i = c; i <= b; i++) freq[i] = 1;
    return b - c + 1;
  }
}
int main() {
  int i, j, k, l, r, p, q, a[55], b[55], c[55], d[55];
  scanf("%d %d %d %d", &p, &q, &l, &r);
  for (i = 0; i < p; i++) scanf("%d %d", &a[i], &b[i]);
  for (i = 0; i < q; i++) scanf("%d %d", &c[i], &d[i]);
  int count = 0;
  for (i = 0; i < q; i++) {
    for (j = 0; j < p; j++) {
      int l1, r1;
      if (c[i] >= a[j] && c[i] <= b[j]) l1 = 0;
      r1 = b[j] - c[i];
      if (c[i] < a[j]) {
        l1 = a[j] - d[i];
        r1 = b[j] - c[i];
      }
      count = count + find_int(l1, r1, l, r);
    }
  }
  count = 0;
  for (i = l; i <= r; i++) {
    if (freq[i] == 1) count++;
  }
  printf("%d\n", count);
  return 0;
}
