#include <bits/stdc++.h>
int a[2005], c[2005], d[2005];
int main() {
  int p, q, l, r, i, cou = 0, m, n, j, tim;
  scanf("%d %d %d %d", &p, &q, &l, &r) == 4;
  cou = 0;
  for (i = 1; i <= p; ++i) {
    scanf("%d %d", &m, &n);
    for (j = m; j <= n; ++j) a[j] = 1;
  }
  for (i = 1; i <= q; ++i) {
    scanf("%d %d", &c[i], &d[i]);
  }
  for (i = l; i <= r; ++i) {
    for (j = 1; j <= q; ++j) {
      for (tim = c[j] + i; tim <= d[j] + i; ++tim) {
        if (a[tim] == 1) {
          ++cou;
          break;
        }
      }
      if (tim <= d[j] + i) break;
    }
  }
  printf("%d\n", cou);
  return 0;
}
