#include <bits/stdc++.h>
using namespace std;
int ans;
int mark[1001];
struct len {
  int l, r;
} a[51], b[51];
int hanshu(int t, int q) {
  int flag = 0;
  for (int i = 0; i < q; i++)
    for (int j = b[i].l + t; j <= min(1000, b[i].r + t); j++)
      if (mark[j]) flag = 1;
  if (flag)
    return 1;
  else
    return 0;
}
int main() {
  int p, q, l, r;
  while (~scanf("%d%d%d%d", &p, &q, &l, &r)) {
    ans = 0;
    memset(a, 0, sizeof(a));
    memset(b, 0, sizeof(b));
    memset(mark, 0, sizeof(mark));
    for (int i = 0; i < p; i++) {
      scanf("%d%d", &a[i].l, &a[i].r);
      for (int j = a[i].l; j <= a[i].r; j++) mark[j] = 1;
    }
    for (int i = 0; i < q; i++) scanf("%d%d", &b[i].l, &b[i].r);
    for (int i = l; i <= r; i++)
      if (hanshu(i, q)) ans++;
    printf("%d\n", ans);
  }
  return 0;
}
