#include <bits/stdc++.h>
using namespace std;
int main() {
  int p, q, l, r, count = 0;
  cin >> p >> q >> l >> r;
  int a[q], b[q];
  map<int, int> mp;
  for (int i = 0; i < p; i++) {
    int x, y;
    cin >> x >> y;
    for (int j = x; j <= y; j++) mp[j]++;
  }
  for (int i = 0; i < q; i++) {
    cin >> a[i] >> b[i];
  }
  for (int i = l; i <= r; i++) {
    int flag = 0;
    for (int j = 0; j < q; j++) {
      for (int k = a[j]; k <= b[j]; k++) {
        if (mp[k + i] >= 1) {
          flag = 1;
          count++;
          break;
        }
      }
      if (flag == 1) break;
    }
  }
  cout << count;
  return 0;
}
