#include <iostream>
#include <bitset>
using namespace std;

int main() {
    bitset<2000> forA;
    bitset<2000> forB;
    int p, q, l, r;
    while(cin >> p >> q >> l >> r){
        int start, end;
        for(int i = 0; i < p; ++i){
            cin >> start >> end;
            for(int j = start; j <= end; ++j)
                forA.set(j);
        }
        for(int i = 0; i < q; ++i){
            cin >> start >> end;
            for(int j = start; j <= end; ++j)
                forB.set(j);
        }
        int ans = 0;
        forB <<= l;
        for(int i = 0; i <= r - l; ++i){
            bitset<2000> cur = forA & forB;
            if(cur.any())
                ans++;
            forB <<= 1;
        }
        cout << ans << endl;
    }
}
// 64 位输出请用 printf("%lld")