#include <bits/stdc++.h>
using namespace std;
vector<pair<int, int> > v, w;
bool check(int t) {
  vector<int> ar(1001, 0);
  for (int i = 0; i < v.size(); ++i) {
    int a = v[i].first;
    int b = v[i].second;
    for (int j = a; j <= b; ++j) {
      ar[j] = 1;
    }
  }
  for (int i = 0; i < w.size(); i++) {
    int a = w[i].first + t;
    int b = w[i].second + t;
    int len = ar.size();
    for (int j = min(a, len - 1); j <= min(b, len); ++j) {
      if (ar[j] == 1) {
        return true;
      }
    }
  }
  return false;
}
void test_case() {
  int p, q, l, r;
  scanf("%d%d%d%d", &p, &q, &l, &r);
  int a, b, c, d;
  for (int i = 1; i <= p; ++i) {
    scanf("%d%d", &a, &b);
    v.push_back({a, b});
  }
  for (int i = 1; i <= q; ++i) {
    scanf("%d%d", &c, &d);
    w.push_back({c, d});
  }
  int ans = 0;
  for (int i = l; i <= r; ++i) {
    if (check(i)) ans++;
  }
  printf("%d\n", ans);
}
int main() {
  int T = 1;
  while (T--) {
    test_case();
  }
}
