#include <bits/stdc++.h>
using namespace std;
int p, q, l, r;
int st[2][1010], en[2][1010];
int ans;
bool can[1010];
int main() {
  int i, j, k;
  scanf("%d%d%d%d", &p, &q, &l, &r);
  for (i = 1; i <= p; i++) scanf("%d%d", &st[0][i], &en[0][i]);
  for (i = 1; i <= q; i++) scanf("%d%d", &st[1][i], &en[1][i]);
  for (i = 1; i <= q; i++) {
    for (j = 1; j <= p; j++)
      for (k = max(l, st[0][j] - en[1][i]); k <= min(r, en[0][j] - st[1][i]);
           k++)
        can[k] = 1;
  }
  for (i = l; i <= r; i++) ans += can[i];
  printf("%d\n", ans);
  return 0;
}
