#include <bits/stdc++.h>
using namespace std;
int a[1005];
int b[2005];
int main() {
  int p, q, l, r;
  cin >> p >> q >> l >> r;
  while (p--) {
    int val1, val2;
    cin >> val1 >> val2;
    for (int i = val1; i <= val2; i++) a[i] = 1;
  }
  while (q--) {
    int val1, val2;
    cin >> val1 >> val2;
    for (int i = val1; i <= val2; i++) b[i + 1000] = 1;
  }
  int count = 0;
  for (int t = l; t <= r; t++)
    for (int i = 0; i <= 1000; i++)
      if (a[i] && b[i + 1000 - t]) {
        count++;
        break;
      }
  cout << count;
  return 0;
}
