#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1000000007;
const int SZ = 10000000 + 1;
vector<int> A, B, C, D;
int L, R, P, Q, RES, xx, yy, mx;
int main(int argc, const char **argv) {
  while (scanf("%d %d %d %d", &P, &Q, &L, &R) == 4) {
    A.clear();
    B.clear();
    C.clear();
    D.clear();
    RES = mx = 0;
    for (int i = 1; i <= P; ++i) {
      scanf("%d %d", &xx, &yy);
      A.push_back(xx);
      B.push_back(yy);
      mx = max(mx, yy);
    }
    for (int i = 1; i <= Q; ++i) {
      scanf("%d %d", &xx, &yy);
      C.push_back(xx);
      D.push_back(yy);
    }
    for (int i = L; i <= R; ++i) {
      bool flag = false;
      for (int j = 0; j <= (Q - 1); ++j) {
        int m = C[j] + i;
        int n = D[j] + i;
        if (m > mx) continue;
        for (int k = 0; k <= (P - 1); ++k) {
          int G = A[k];
          int H = B[k];
          if ((G <= m and m <= H) or (G <= n and n <= H) or
              (m <= G and G <= n) or (m <= H and H <= n)) {
            flag = true;
          }
        }
      }
      if (flag) RES++;
    }
    printf("%d\n", RES);
  }
  return 0;
}
