#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace std;
using namespace __gnu_pbds; 
 
template <typename T>
using oset = tree<T, null_type, less<T>, rb_tree_tag, 
tree_order_statistics_node_update>;
template <typename T>
using omultiset = tree<T, null_type, less_equal<T>, rb_tree_tag, 
tree_order_statistics_node_update>;

#define ll long long
#define pb push_back
#define mp make_pair
#define umap unordered_map
#define fr(i,a,b) for(int i=a;i<b;i++)
const int mx=1e7+5;
const int mod=1e9+7;
#define deb(x) cout<<x<<endl;
#define debl(x) cout<<x<<" ";
#define spair(p) cout<<"("<<p.first<<","<<p.second<<")"<<endl;
int gcdExtended(int a, int b, int* x, int* y)
{
    if (a == 0)
    {
        *x = 0, *y = 1;
        return b;
    }
 
    int x1, y1; // To store results of recursive call
    int gcd = gcdExtended(b % a, a, &x1, &y1);
    *x = y1 - (b / a) * x1;
    *y = x1;
 
    return gcd;
}
 
ll modInverse(ll a, ll m)
{
    int x, y;
    int g = gcdExtended(a, m, &x, &y);
    if (g != 1)
        return 0;
    else
    {
        // m is added to handle negative x
        ll res = (x % m + m) % m;
        return res;
    }
}
 
ll nCr(int n, int r,int m){
    if(r>n){
        return 0;
    }
    if(r>n-r){
        r = n-r;
    }
    ll ans = 1;
    for(int i = 1; i<=r ; i++){
        ans *= (n-i+1);
        ans%= m;
        ans *= modInverse(i, m);
        ans %= m;       
    }
    return ans;
}
long long binpow(long long a, long long b) {
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}
long long binpow(long long a, long long b, long long m)
{
    a %= m;
    long long res = 1;
    while (b > 0)
    {
        if (b & 1)
            res = res * a % m;
        a = a * a % m;
        b >>= 1;
    }
    return res;
}
template<typename u,typename v>
auto min(u a,v b)
{
    return a>b ? b:a;
}
template<typename u,typename v>
auto max(u a,v b)
{
    return a<b?b:a;
}

void solve()
{

}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin>>n;
    int val;
    set<int> a,b;
    for(int i=0;i<n;i++)
    {
        cin>>val;
        a.insert(val);
    }
    for(int i=0;i<n;i++)
    {
        cin>>val;
        b.insert(val);
    }
    int max=*(b.begin());
    int min=*a.rbegin();
    if(min > max)
    {
        deb(0);
        return 0;
    }
    deb(max - min + 1);
}

/**
 * Dont raise your voice, improve your argument.
 * --Desmond Tutu
 */

#include <bits/stdc++.h>
using namespace std;

const bool ready = [](){
    ios_base::sync_with_stdio(false); cin.tie(0);
    cout << fixed << setprecision(12);
    return true;
}();

const double PI = acos(-1);
using ll= long long;
#define int ll
#define all(v) (v).begin(), (v).end()
#define fori(n) for(int i=0; i<int(n); i++)

#define cini(i) int i; cin>>i;
#define cins(s) string s; cin>>s;
#define cind(d) double d; cin>>d;
#define cinai(a,n) vi a(n); fori(n) { cin>>a[i]; }
#define cinas(s,n) vs s(n); fori(n) { cin>>s[i]; }
#define cinad(a,n) vd a(n); fori(n) { cin>>a[i]; }

using pii= pair<int, int>;
using pdd= pair<double, double>;
using vd= vector<double>;
using vb= vector<bool>;
using vvb= vector<vb>;
using vi= vector<int>;
using vvi= vector<vi>;
using vs= vector<string>;

#define endl "\n"

/* We need to find foreach bulb the leftnearsest and rightnearest blocks.
 * But what about overcount?
 *
 * We count to N and W up to next bulb or block.
 * We count to S and E only if the next block is more near than the next bulb.
 *
 * fu.. This does not work, consider horizontal illuminated fields
 * and vertical ones. They intersect!
 *
 * Can we maintain segment trees and do range updates?
 *
 * -> Consider all four direction separate.
 */
void solve() {
    cini(h);
    cini(w);
    cini(n);
    cini(m);

    vvb bu(h, vb(w));
    vvb bl(h, vb(w));
    for(int i=0; i<n; i++)  {
        cini(r); r--;
        cini(c); c--;
        bu[r][c]=true;
    }
    for(int i=0; i<m; i++)  {
        cini(r); r--;
        cini(c); c--;
        bl[r][c]=true;
    }

    vvb ans(h, vb(w));
        /* dir E */
    for(int i=0; i<h; i++) {
        int on=false;
        for(int j=0; j<w; j++) {
            if(bu[i][j])
                on=true;
            else if(bl[i][j])
                on=false;

            if(on)
                ans[i][j]=true;
        }
    }
        /* dir W */
    for(int i=0; i<h; i++) {
        int on=false;
        for(int j=w-1; j>=0; j--) {
            if(bu[i][j])
                on=true;
            else if(bl[i][j])
                on=false;

            if(on)
                ans[i][j]=true;
        }
    }

        /* dir S */
    for(int j=0; j<w; j++) {
        int on=false;
        for(int i=0; i<h; i++) {
            if(bu[i][j])
                on=true;
            else if(bl[i][j])
                on=false;

            if(on)
                ans[i][j]=true;
        }
    }

        /* dir N */
    for(int j=0; j<w; j++) {
        int on=false;
        for(int i=h-1; i>=0; i--) {
            if(bu[i][j])
                on=true;
            else if(bl[i][j])
                on=false;

            if(on)
                ans[i][j]=true;
        }
    }

    int ansv=0;
    for(int i=0; i<h; i++) 
        for(int j=0; j<w; j++)  {
            if(ans[i][j])
                ansv++;
        }

    cout<<ansv<<endl;
}

signed main() {
    solve();
}

// FIRST THINK, THEN CODE
// DO NOT JUMP BETWEEN PROBLEMS
