#include <bits/stdc++.h>
using namespace std;
const int maxn = 100 + 10;
int p, q, l, r;
pair<int, int> t1[maxn], t2[maxn];
int mark[maxn * 20];
int ans = 0;
bool chk(int t);
int main() {
  ios ::sync_with_stdio(false);
  cin.tie(0);
  cin >> p >> q >> l >> r;
  for (int i = 0; i < p; i++) cin >> t1[i].first >> t1[i].second;
  for (int i = 0; i < q; i++) cin >> t2[i].first >> t2[i].second;
  for (int i = l; i <= r; i++) {
    fill(mark, mark + maxn * 20, 0);
    ans += chk(i);
  }
  cout << ans << endl;
  return 0;
}
bool chk(int t) {
  for (int i = 0; i < q; i++)
    for (int j = t2[i].first; j <= t2[i].second; j++) mark[t + j]++;
  for (int i = 0; i < p; i++)
    for (int j = t1[i].first; j <= t1[i].second; j++) mark[j]++;
  for (int i = 0; i < maxn * 20; i++)
    if (mark[i] >= 2) return true;
  return false;
}
