#include <bits/stdc++.h>
using namespace std;
void solve() {
  int p, q, l, r;
  cin >> p >> q >> l >> r;
  int ans = 0;
  int arr[p][2], brr[q][2];
  for (int i = 0; i < p; i++) cin >> arr[i][0] >> arr[i][1];
  for (int i = 0; i < q; i++) cin >> brr[i][0] >> brr[i][1];
  for (int i = l; i <= r; i++) {
    bool f = 0;
    for (int x = 0; x < q; x++) {
      int t1 = brr[x][0] + i;
      int t2 = brr[x][1] + i;
      for (int j = 0; j < p; j++) {
        if ((arr[j][0] <= t1 and arr[j][1] >= t1) or
            (arr[j][0] <= t2 and arr[j][1] >= t2) or
            (t1 < arr[j][0]) and t2 > arr[j][1]) {
          f = 1;
        }
        if (f) break;
      }
      if (f) break;
    }
    if (f) ans++;
  }
  cout << ans;
}
void file_i_o() {}
int main() {
  file_i_o();
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int t = 1;
  while (t--) {
    solve();
  }
}
