#include <bits/stdc++.h>
using namespace std;
set<int> s;
int main() {
  int a[55], b[55], c[55], d[55];
  int q, p, l, r;
  cin >> p >> q >> l >> r;
  for (int i = 0; i < p; i++) cin >> a[i] >> b[i];
  for (int i = 0; i < q; i++) cin >> c[i] >> d[i];
  for (int i = l; i <= r; i++) {
    int n = 0;
    for (int j = 0; j < q; j++)
      for (int k = 0; k < p; k++)
        if (c[j] + i > b[k] || d[j] + i < a[k])
          continue;
        else
          s.insert(i);
  }
  cout << s.size();
}
