#include <bits/stdc++.h>
int count[100001];
int main() {
  int a, c, p, q, l, r, arr[51][2], crr[51][2];
  scanf("%d %d %d %d", &p, &q, &l, &r);
  int i, j, y, x;
  for (i = 0; i < p; i++) {
    scanf("%d %d", &arr[i][0], &arr[i][1]);
  }
  for (i = 0; i < q; i++) {
    scanf("%d %d", &crr[i][0], &crr[i][1]);
  }
  int ans = 0;
  for (i = l; i <= r; i++) {
    for (j = 0; j < q; j++) {
      c = 0;
      for (a = 0; a < p; a++) {
        if (crr[j][0] + i >= arr[a][0] && crr[j][0] + i <= arr[a][1] ||
            crr[j][1] + i >= arr[a][0] && crr[j][0] + i <= arr[a][1]) {
          ans++;
          c = 1;
          break;
        }
      }
      if (c == 1) {
        break;
      }
    }
  }
  printf("%d\n", ans);
  return 0;
}
