#include <bits/stdc++.h>
using namespace std;
struct _ {
  ios_base::Init i;
  _() {
    cin.sync_with_stdio(0);
    cin.tie(0);
  }
} _;
int n, m;
int main() {
  string a;
  int p, q, l, r;
  cin >> p >> q >> l >> r;
  vector<bool> z(1001, false);
  for (int i = 0; i < 2 * p; i += 2) {
    int a, b;
    cin >> a >> b;
    fill(z.begin() + a, z.begin() + b + 1, true);
  }
  int res = 0;
  vector<int> x(2 * q);
  for (int i = 0; i < 2 * q; i += 2) {
    cin >> x[i] >> x[i + 1];
  }
  int N = 1001;
  for (int sh = l; sh <= r; ++sh) {
    for (int i = 0; i < 2 * q; i += 2) {
      bool breakFlag = false;
      for (int j = x[i] + sh; j < min(x[i + 1] + sh + 1, N); ++j) {
        if (z[j]) {
          ++res;
          ;
          breakFlag = true;
          break;
        }
      }
      if (breakFlag) break;
    }
  }
  cout << res << endl;
  return 0;
}
