#include <bits/stdc++.h>
using namespace std;
struct interval {
  int start;
  int end;
};
int main() {
  int p, q, l, r;
  cin >> p >> q >> l >> r;
  struct interval Z[p];
  for (int i = 0; i < p; i++) {
    cin >> Z[i].start >> Z[i].end;
  }
  struct interval X[q];
  for (int i = 0; i < q; i++) {
    cin >> X[i].start >> X[i].end;
  }
  int count = 0;
  for (int i = l; i <= r; i++) {
    for (int j = 0; j < p; j++) {
      int flag = 0;
      for (int k = 0; k < q; k++) {
        if ((Z[j].start >= (X[k].start + i) && Z[j].end <= (X[k].end + i)) ||
            ((X[k].start + i) >= Z[j].start && (X[k].end + i) <= Z[j].end) ||
            (Z[j].start >= (X[k].start + i) && Z[j].start <= (X[k].end + i)) ||
            (Z[j].end >= (X[k].start + i) && Z[j].end <= (X[k].end + i)) ||
            ((X[k].start + i) >= Z[j].start && (X[k].start + i) <= Z[j].end) ||
            ((X[k].end + i) >= Z[j].start && (X[k].end + i) <= Z[j].end)) {
          count++;
          flag = 1;
          break;
        }
      }
      if (flag) break;
    }
  }
  cout << count << endl;
  return 0;
}
