#include <bits/stdc++.h>
using namespace std;
template <typename T>
void print2dvector(vector<vector<T> > v) {
  cout << "A 2d vector:" << endl;
  int a = v.size();
  int b = v[0].size();
  if (a <= 15 && b <= 15) {
    for (int i = 0; i < a; i++) {
      for (int j = 0; j < b; j++) {
        cout << setw(4) << v[i][j];
      }
      cout << endl;
    }
  }
  if (a > 15 && b > 15) {
    for (int i = 0; i < 9; i++) {
      for (int j = 0; j < 9; j++) {
        cout << setw(4) << v[i][j];
      }
      cout << "   "
           << ".   .   ." << setw(4) << v[i][b - 3] << setw(4) << v[i][b - 2]
           << setw(4) << v[i][b - 1] << endl;
    }
    for (int i = 0; i < 15; i++) {
      cout << setw(4) << '.';
    }
    cout << endl;
    for (int i = a - 3; i < a; i++) {
      for (int j = 0; j < 9; j++) {
        cout << setw(4) << v[i][j];
      }
      cout << "   "
           << ".   .   ." << setw(4) << v[i][b - 3] << setw(4) << v[i][b - 2]
           << setw(4) << v[i][b - 1] << endl;
    }
  }
  if (a > 15) {
    for (int i = 0; i < 9; i++) {
      for (int j = 0; j < b; j++) {
        cout << setw(4) << v[i][j];
      }
      cout << endl;
    }
    for (int i = 0; i < b; i++) {
      cout << setw(4) << '.';
    }
    cout << endl;
    for (int i = a - 3; i < a; i++) {
      for (int j = 0; j < b; j++) {
        cout << setw(4) << v[i][j];
      }
      cout << endl;
    }
  }
  if (b > 15) {
    for (int i = 0; i < a; i++) {
      for (int j = 0; j < 9; j++) {
        cout << setw(4) << v[i][j];
      }
      cout << "   "
           << ".   .   ." << setw(4) << v[i][b - 3] << setw(4) << v[i][b - 2]
           << setw(4) << v[i][b - 1] << endl;
    }
  }
}
template <typename T>
void printvector(vector<T> v) {
  cout << "A 1d vector:" << endl;
  int a = v.size();
  if (a <= 15) {
    for (int i = 0; i < a; i++) {
      cout << setw(4) << v[i];
    }
  } else {
    for (int i = 0; i < 9; i++) {
      cout << setw(4) << v[i];
    }
    cout << "   "
         << ".   .   ." << setw(4) << v[a - 3] << setw(4) << v[a - 2] << setw(4)
         << v[a - 1];
  }
  cout << endl;
}
int p, q, l, r;
bool is_suitable(vector<pair<int, int> > z, vector<pair<int, int> > x, int t) {
  for (int i = 0; i < z.size(); i++) {
    for (int j = 0; j < x.size(); j++) {
      if (z[i].second >= x[j].first + t && x[j].second + t >= z[i].first) {
        return true;
      }
    }
  }
  return false;
}
int main() {
  scanf("%d %d %d %d", &p, &q, &l, &r);
  vector<pair<int, int> > z(p);
  vector<pair<int, int> > x(q);
  int a, b;
  for (int i = 0; i < p; i++) {
    scanf("%d %d", &a, &b);
    if (a > b) {
      swap(a, b);
    }
    z[i] = make_pair(a, b);
  }
  for (int i = 0; i < q; i++) {
    scanf("%d %d", &a, &b);
    if (a > b) {
      swap(a, b);
    }
    x[i] = make_pair(a, b);
  }
  int ct = 0;
  for (int i = l; i <= r; i++) {
    if (is_suitable(z, x, i)) {
      ct++;
    }
  }
  printf("%d\n", ct);
  return 0;
}
