#include <bits/stdc++.h>
using namespace std;
bool isprime(int n) {
  for (int i = sqrt(n); i > 1; i--) {
    if (n % i == 0) return false;
  }
  return true;
}
bool is_int(long double d) {
  if (d == ceil(d)) return true;
  return false;
}
long long fact(int x) {
  if (x == 0 || x == 1)
    return 1;
  else
    return x * fact(x - 1);
}
long long ncr(long long n, long long r) {
  return (fact(n) / (fact(r) * fact(n - r)));
}
long long gcd(long long n, long long m) {
  if (n % m == 0) return m;
  if (n < m) swap(n, m);
  while (m > 0) {
    n = n % m;
    swap(n, m);
  }
  return n;
}
bool isPowerOfTwo(int n) {
  if (n == 0) return false;
  return (ceil(log2(n)) == floor(log2(n)));
}
int binary_search(int x, int low, int high, int arr[]) {
  if (low == high)
    return low;
  else {
    int mid = (low + high) / 2;
    if (arr[mid] == x)
      return mid;
    else if (arr[mid] > x)
      return binary_search(x, low, mid - 1, arr);
    else
      return binary_search(x, mid + 1, high, arr);
  }
  return -1;
}
void solve() {
  int p, q, l, r;
  cin >> p >> q >> l >> r;
  int max = 0;
  vector<int> v(100000, 0);
  for (long long i = 0; i < p; i++) {
    int a, b;
    cin >> a >> b;
    if (b > max) max = b;
    for (long long j = a; j <= b; j++) v[j] = 1;
  }
  int count{};
  vector<pair<int, int>> v1;
  for (long long i = 0; i < q; i++) {
    int x, y;
    cin >> x >> y;
    v1.push_back(make_pair(x, y));
  }
  for (long long i = l; i <= r; i++) {
    for (long long j = 0; j < q; j++) {
      int start = v1[j].first + i;
      int end = v1[j].second + i;
      if (true) {
        auto it = find(v.begin() + start, v.begin() + end + 1, 1);
        if (it - v.begin() != end + 1) {
          count++;
          break;
        }
      }
    }
  }
  cout << count << "\n";
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ;
  int q = 1;
  while (q--) {
    solve();
  }
  return 0;
}
