#include <bits/stdc++.h>
using namespace std;
int main() {
  int p, q, l, r;
  cin >> p >> q >> l >> r;
  int a[p], b[p], c[q], d[q];
  for (int i = 0; i < p; i++) cin >> a[i] >> b[i];
  for (int i = 0; i < q; i++) cin >> c[i] >> d[i];
  int x = 0;
  for (int i = l; i <= r; i++) {
    for (int j = 0; j < p; j++) {
      bool check = false;
      for (int k = 0; k < q; k++) {
        if (c[k] + i > b[j] || d[k] + i < a[j])
          continue;
        else {
          x++;
          check = true;
          break;
        }
      }
      if (check) {
        break;
      }
    }
  }
  cout << x;
  return 0;
}
