#include <bits/stdc++.h>
using namespace std;
struct node {
  int st;
  int en;
} P[55], Q[55];
bool cmp(const node &a, const node &b) { return a.st < b.st; }
int p, q, l, r;
bool solve(int n) {
  for (int i = 0; i < p; i++) {
    for (int j = 0; j < q; j++) {
      if (Q[j].st + n <= P[i].st && Q[j].en + n >= P[i].st) {
        return true;
      } else if (Q[j].st + n <= P[i].en && Q[j].en + n >= P[i].en) {
        return true;
      } else if (Q[j].st + n >= P[i].st && Q[j].en + n <= P[i].en) {
        return true;
      }
    }
  }
  return false;
}
int main() {
  while (scanf("%d%d%d%d", &p, &q, &l, &r) == 4) {
    for (int i = 0; i < p; i++) {
      int temp1, temp2;
      scanf("%d%d", &temp1, &temp2);
      P[i].st = temp1;
      P[i].en = temp2;
    }
    for (int i = 0; i < q; i++) {
      int temp1, temp2;
      scanf("%d%d", &temp1, &temp2);
      Q[i].st = temp1;
      Q[i].en = temp2;
    }
    sort(P, P + p, cmp);
    sort(Q, Q + q, cmp);
    int ans = 0;
    for (int i = l; i <= r; i++) {
      if (solve(i)) ans++;
    }
    printf("%d\n", ans);
  }
  return 0;
}
