#include <bits/stdc++.h>
using namespace std;
int n, p, q, l, r, ans = 0;
int vis[3456];
vector<pair<int, int> > a, b;
int main() {
  cin >> p >> q >> l >> r;
  for (int i = 0; i < p; i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    a.push_back(make_pair(x, y));
  }
  for (int i = 0; i < q; i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    b.push_back(make_pair(x, y));
  }
  for (int i = l; i <= r; i++) {
    for (int j = 0; j < 3024; j++) vis[j] = 0;
    for (int j = 0; j < p; j++) {
      int one = a[j].first;
      int two = a[j].second;
      vis[one]++;
      vis[two + 1]--;
    }
    for (int j = 0; j < q; j++) {
      int one = b[j].first + i;
      int two = b[j].second + i;
      vis[one]++;
      vis[two + 1]--;
    }
    for (int j = 1; j < 3024; j++) {
      vis[j] = vis[j - 1] + vis[j];
      if (vis[j] > 1) {
        ans++;
        break;
      }
    }
  }
  cout << ans;
}
