#include <bits/stdc++.h>
using namespace std;
const long long int N = 2e6 + 5;
void solve() {
  long long int p, q, l, r;
  cin >> p >> q >> l >> r;
  vector<pair<long long int, long long int>> x, z;
  for (long long int i = 0; i < p; i++) {
    long long int a, b;
    cin >> a >> b;
    x.push_back({a, b});
  }
  for (long long int i = 0; i < q; i++) {
    long long int a, b;
    cin >> a >> b;
    z.push_back({a, b});
  }
  long long int ans = 0;
  for (long long int i = l; i <= r; i++) {
    bool flag = false;
    for (long long int j = 0; j < p; j++) {
      for (long long int k = 0; k < q; k++) {
        if (x[j].first >= z[k].first + i and x[j].first <= z[k].second + i)
          flag = true;
        if (z[k].first + i >= x[j].first and z[k].first + i <= x[j].second)
          flag = true;
      }
    }
    if (flag) ans++;
  }
  cout << ans << endl;
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  solve();
}
