// ConsoleApplication5.cpp : 定义控制台应用程序的入口点。
//
#include "stdafx.h"
#include<vector>
#include<iostream>
#include<string>
#include <stack>
#include<algorithm>
using namespace std;
bool compVec(vector<int> vec1, vector<int> vec2 )
{
bool flag = false;
for (int i = 0; i < vec1.size();i++)
{
for (int j = 0; j < vec2.size(); j++)
{
if (vec1[i] == vec2[j])
{
flag = true;
break;
}
}
if (flag == true)
{
break;
}
}
//cout << "执行了" << endl;
return flag;
}
int main()
{
int p,q,l,r;
while (cin >> p>>q>>l>>r)
{
vector<int> vec1;
vector<int> vec2;
int num = 0;
for (int i = 0; i < p; i++)
{
int a, b;
cin >> a >> b;
for (int j = a; j <= b; j++)
{
vec1.push_back(j);
}
}
for (int i = 0; i < q; i++)
{
int a, b;
cin >> a >> b;
for (int j = a ; j <= b ; j++)
{
vec2.push_back(j);
}
}
for (int k = l; k <= r; k++)
{
for (int i = 0; i < vec2.size(); i++)
{
vec2[i] = vec2[i] + k;
}
if (compVec(vec1, vec2) == true)
{
num++;
}
for (int i = 0; i < vec2.size(); i++)
{
vec2[i] = vec2[i] - k;
}
}
cout << num << endl;
}
return 0;
}