#include <bits/stdc++.h>
using namespace std;
int main() {
  int p, q, l, r;
  cin >> p >> q >> l >> r;
  int a[p], b[p];
  int t[2011] = {0};
  for (int i = 0; i < p; i++) {
    cin >> a[i] >> b[i];
    for (int j = a[i]; j <= b[i]; j++) {
      t[j] = 1;
    }
  }
  int c[q], d[q];
  for (int j = 0; j < q; j++) {
    cin >> c[j] >> d[j];
  }
  int ans = 0;
  for (int i = l; i <= r; i++) {
    int flag = 1;
    for (int j = 0; j < q; j++) {
      int m = c[j] + i;
      int n = d[j] + i;
      for (int k = m; k <= n; k++) {
        if (t[k]) {
          flag = 0;
          break;
        }
      }
    }
    if (flag == 0) {
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}
