#include <bits/stdc++.h>
int a[2005], b[2005], ans = 0;
int main() {
  int p, q, l, r;
  int i, j, x, y, max = -1;
  scanf("%d%d%d%d", &p, &q, &l, &r);
  for (i = 0; i < p; i++) {
    scanf("%d%d", &x, &y);
    for (j = x; j <= y; j++) a[j] = 1;
  }
  for (i = 0; i < q; i++) {
    scanf("%d%d", &x, &y);
    if (y > max) max = y;
    for (j = x; j <= y; j++) b[j] = 1;
  }
  for (i = l; i <= r; i++) {
    for (j = 0; j <= max; j++) {
      if (b[j] && a[j + i]) {
        ans++;
        break;
      }
    }
  }
  printf("%d", ans);
  return 0;
}
