#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int p, q, l, r;
  cin >> p >> q >> l >> r;
  vector<pair<int, int> > z_timing, x_timing;
  int start, stop;
  for (int i = 0; i < p; i++) {
    cin >> start >> stop;
    z_timing.push_back(make_pair(start, stop));
  }
  for (int i = 0; i < q; i++) {
    cin >> start >> stop;
    x_timing.push_back(make_pair(start, stop));
  }
  int answer = 0;
  for (int i = l; i <= r; i++) {
    for (int j = 0; j < q; j++) {
      bool has_intersected = false;
      start = x_timing[j].first + i;
      stop = x_timing[j].second + i;
      for (int k = 0; k < p; k++) {
        if (start <= z_timing[k].second && stop >= z_timing[k].first) {
          answer++;
          has_intersected = true;
          break;
        }
      }
      if (has_intersected == true) {
        break;
      }
    }
  }
  cout << answer;
  return 0;
}
