#include <bits/stdc++.h>
using namespace std;
int main() {
  int a[3010], x, y, c[100], d[100], n, l, r, time, count = 0, p, q, i, j;
  scanf("%d%d%d%d", &p, &q, &l, &r);
  memset(a, 0, sizeof(a));
  while (p--) {
    scanf("%d%d", &x, &y);
    for (i = x; i <= y; i++) a[i]++;
  }
  for (i = 0; i < q; i++) {
    scanf("%d%d", &c[i], &d[i]);
  }
  for (time = l; time <= r; time++) {
    for (i = 0; i < q; i++) {
      int flag = 0;
      for (j = c[i] + time; j <= d[i] + time; j++) {
        if (a[j] > 0) {
          count++;
          flag++;
          break;
        }
      }
      if (flag > 0) {
        break;
      }
    }
  }
  printf("%d\n", count);
  return 0;
}
