#include <bits/stdc++.h>
using namespace std;
int main() {
  int z[3050] = {0}, x[3050] = {0}, p, q, l, r, a, b, c, d, n = 0;
  scanf("%d %d %d %d ", &p, &q, &l, &r);
  for (int i = 1; i <= p; i++) {
    scanf("%d %d", &a, &b);
    for (int j = a; j <= b; j++) z[j] = 1;
  }
  for (int i = 1; i <= q; i++) {
    scanf("%d %d", &c, &d);
    for (int j = l; j <= r; j++) {
      for (int k = c + j; k <= d + j; k++) {
        if (z[k] == 1) {
          x[j] = 1;
          break;
        }
      }
    }
  }
  for (int i = l; i <= r; i++)
    if (x[i]) n++;
  printf("%d ", n);
}
