#include <bits/stdc++.h>
using namespace std;
struct {
  int begin, end;
} P1[60], P2[60];
int main() {
  int num1, num2, first, last;
  scanf("%d %d %d %d", &num1, &num2, &first, &last);
  int ans = 0;
  for (int i = 1; i <= num1; i++) scanf("%d %d", &P1[i].begin, &P1[i].end);
  for (int i = 1; i <= num2; i++) scanf("%d %d", &P2[i].begin, &P2[i].end);
  for (int i = first; i <= last; i++) {
    for (int j1 = 1; j1 <= num1; j1++) {
      bool flag = 1;
      for (int j2 = 1; j2 <= num2; j2++) {
        if ((P2[j2].begin + i >= P1[j1].begin &&
             P2[j2].begin + i <= P1[j1].end) ||
            (P2[j2].end + i >= P1[j1].begin && P2[j2].end + i <= P1[j1].end) ||
            (P2[j2].begin + i <= P1[j1].begin &&
             P2[j2].end + i >= P1[j1].end)) {
          ans++;
          flag = 0;
          break;
        }
      }
      if (!flag) break;
    }
  }
  printf("%d\n", ans);
  return 0;
}
