#include <bits/stdc++.h>
using namespace std;
const int MAX = 55;
int p, q, l, r, sol = 0;
pair<int, int> Z[MAX], X[MAX];
int main() {
  scanf("%d%d%d%d", &p, &q, &l, &r);
  for (int i = 0; i < p; i++) scanf("%d%d", &Z[i].first, &Z[i].second);
  for (int i = 0; i < q; i++) scanf("%d%d", &X[i].first, &X[i].second);
  int t = l;
  while (t <= r) {
    bool exit = 0;
    for (int j = 0; j < p; j++) {
      for (int k = 0; k < q; k++) {
        if (max(X[k].first + t, Z[j].first) <=
            min(X[k].second + t, Z[j].second)) {
          exit = 1;
          break;
        }
      }
    }
    if (exit) sol++;
    t++;
  }
  printf("%d", sol);
  return 0;
}
