#include <bits/stdc++.h>
using namespace std;
const int Nmax = 5017;
bool a[Nmax] = {0}, rez[Nmax] = {0};
int ans = 0;
int main(void) {
  std::ios::sync_with_stdio(false);
  int p, q, l, r;
  cin >> p >> q >> l >> r;
  int x, y;
  while (p--) {
    cin >> x >> y;
    for (; x <= y; x++) a[x] = 1;
  }
  while (q--) {
    cin >> x >> y;
    for (int i = l; i <= r; i++)
      for (int z = x + i; z <= 1000 && z <= y + i; z++)
        if (a[z]) {
          if (rez[i] == 0) {
            ans++;
            rez[i] = 1;
            break;
          }
        }
  }
  cout << ans;
}
