#include <bits/stdc++.h>
using namespace std;
int p, q, l, r, res = 0;
vector<bool> vis(10000, 0);
int a[500005];
int b[100];
int c[100];
int d[100];
int c1[100];
int d1[100];
bool fun() {
  for (int i = 0; i < q; i++)
    for (int h = c1[i]; h <= d1[i]; h++) {
      if (vis[h] == 1) return 1;
    }
  return 0;
}
int main() {
  cin >> p >> q >> l >> r;
  for (int i = 0; i < p; i++) cin >> a[i] >> b[i];
  for (int i = 0; i < q; i++) cin >> c[i] >> d[i];
  for (int i = 0; i < p; i++) {
    for (int l = a[i]; l <= b[i]; l++) vis[l] = 1;
  }
  for (int t = l; t <= r; t++) {
    for (int i = 0; i < q; i++) {
      c1[i] = c[i] + t;
      d1[i] = d[i] + t;
    }
    if (fun()) res++;
  }
  cout << res << endl;
}
