#include <bits/stdc++.h>
using namespace std;
int p, q, l, r, x, y, z, a[2002], b[1001];
int main() {
  cin >> p >> q >> l >> r;
  while (p--) {
    cin >> x >> y;
    while (y >= x) {
      a[y] = 1;
      y--;
    }
  }
  while (q--) {
    cin >> x >> y;
    while (y >= x) {
      b[y] = 1;
      y--;
    }
  }
  while (l <= r) {
    for (int i = 0; i <= 1000; i++)
      if (b[i] && a[i + l]) {
        z++;
        break;
      }
    l++;
  }
  cout << z << endl;
  return 0;
}
