#include <bits/stdc++.h>
using namespace std;
// #include <ext/pb_ds/assoc_container.hpp>
// using namespace __gnu_pbds;
//indexed set is using "int" here--------- use ll ...
// typedef tree <int,null_type,less <int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
// #include <ext/rope>
// using namespace __gnu_cxx;
typedef long long int ll;
typedef long double ld;
#define FAST                 \
    ios::sync_with_stdio(0); \
    cin.tie(0);              \
    cout.tie(0);
#define rep(g, i, n) for (ll g = i; g < n; g++)
#define rev(g, n, i) for (ll g = n - 1; g >= i; g--)
#define all(v) v.begin(), v.end()
#define pb push_back
#define mxe(v) *max_element(v.begin(), v.end())
#define mne(v) *min_element(v.begin(), v.end())
#define ve vector
#define lb lower_bound
#define ub upper_bound
#define rem 1000000007
#define PI 3.141592653589793238462643383279502
ll power(ll x, ll y, ll p)
{
    ll res = 1; // Initialize result
    x = x % p;  // Update x if it is more than or
    while (y > 0)
    {
        if (y & 1)
            res = (res * x) % p;
        y = y >> 1; // y = y/2
        x = (x * x) % p;
    }
    return res;
}
ll modInverse(ll n, ll p)
{
    return power(n, p - 2, p);
}
int main()
{
    FAST
    // freopen("input1.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    /*ll tests;
    cin>>tests;
    rep (gg,0,tests)
    {}*/
    string a,b;
    cin>>a>>b;
    ll x=0,y=0;
    for (auto z: a)
    {
        x+=(z-'0');
    }
    for (auto z: b)
    {
        y+=(z-'0');
    }
    cout<<max(x,y)<<"\n";
}

#include <bits/stdc++.h>
using namespace std;
 
#define pb push_back
#define FOR(i,f,n) for(int i=f;i<n;i++)
#define FORI(i,f,n) for(int i=f;i>=n;i--)
#define sz(a) ((int)(a).size())
#define ff first
#define ss second
#define all(a) (a).begin(),(a).end()
#define alli(a) (a).rbegin(),(a).rend()
#define approx(a) fixed<<setprecision(a)
#define trav(a,x) for(auto& a : x)
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<int,bool> pib;
typedef pair<ll,bool> plb;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<ld> vld;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
template <class T> using pq = priority_queue<T>;
template <class T> using pqg = priority_queue<T, vector<T>, greater<T>>;
template <class T> void ckmin(T &a, const T &b) { a = min(a, b); }
template <class T> void ckmax(T &a, const T &b) { a = max(a, b); }
 
template <class T> void read(vector<T> &v);
template <class F, class S> void read(pair<F, S> &p);
template <class T> void read(T &x) {cin>>x;}
template <class R, class... T> void read(R& r, T&... t){read(r); read(t...);};
template <class T> void read(vector<T> &v) {trav(x, v) read(x);}
template <class F, class S> void read(pair<F, S> &p) {read(p.ff, p.ss);}
 
template <class F, class S> void pr(const pair<F, S> &x);
template <class T> void pr(const T &x) {cout<<x;}
template <class R, class... T> void pr(const R& r, const T&... t) {pr(r); pr(t...);}
template <class F, class S> void pr(const pair<F, S> &x) {pr("{", x.ff, ", ", x.ss, "}");}
void ps() {pr("\n");}
template <class T> void ps(const T &x) {pr(x); ps();}
template <class T> void ps(vector<T> &v) {trav(x, v) pr(x, ' '); ps();}
template <class F, class S> void ps(const pair<F, S> &x) {pr(x.ff, ' ', x.ss); ps();}
template <class R, class... T> void ps(const R& r,  const T &...t) {pr(r, ' '); ps(t...);}

int h, w, n, m;

void solve(){
    read(h, w, n, m);
    vector<vi> grid(h, vi(w));
    FOR(i,0,n){
        int x, y; read(x,y);
        x--, y--;
        grid[x][y] = 1;
    }
    FOR(i,0,m){
        int x, y; read(x,y);
        x--, y--;
        grid[x][y] = -1;
    }
    vector<vi> row = grid;
    vector<vi> col = grid;
    FOR(i,0,h){
        FOR(j,1,w){
            if(row[i][j] != -1 && row[i][j-1] == 1){
                row[i][j] = 1;
            }
        }
        FORI(j,w-2,0){
            if(row[i][j] != -1 && row[i][j+1] == 1){
                row[i][j] = 1;
            }
        }
    }
    FOR(j,0,w){
        FOR(i,1,h){
            if(col[i][j] != -1 && col[i-1][j] == 1){
                col[i][j] = 1;
            }
        }
        FORI(i,h-2,0){
            if(col[i][j] != -1 && col[i+1][j] == 1){
                col[i][j] = 1;
            }
        }
    }

    int ans = 0;
    FOR(i,0,h){
        FOR(j,0,w){
            if(row[i][j] == 1 || col[i][j] == 1) ans++;
        }
    }
    ps(ans);
}
 
int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    int t=1;
    //cin>>t;
    while(t--){
        solve();
    }
}