#include <bits/stdc++.h>
using namespace std;
int littlex[1005] = {0};
vector<int> littleY;
bool isChat(int t) {
  for (int i = 0; i < littleY.size(); i++) {
    if (t + littleY[i] > 1000) {
      break;
    }
    if (littlex[t + littleY[i]]) {
      return true;
    }
  }
  return false;
}
int main() {
  int p, q, l, r, x, y;
  scanf("%d %d %d %d", &p, &q, &l, &r);
  for (int i = 0; i < p; i++) {
    scanf("%d %d", &x, &y);
    for (int i = x; i <= y; i++) {
      littlex[i] = 1;
    }
  }
  for (int i = 0; i < q; ++i) {
    scanf("%d %d", &x, &y);
    for (int i = x; i <= y; i++) {
      littleY.push_back(i);
    }
  }
  int total = 0;
  for (int i = l; i <= r; ++i) {
    if (isChat(i)) {
      total++;
    }
  }
  cout << total << endl;
  return 0;
}
