#include <bits/stdc++.h>
using namespace std;
#define mp make_pair
#define pb push_back
#define ll long long
#define rep(i,N) for(ll i=0; i<N; i++)
const int mx = 2e5;

ll modpow(ll a, ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

int main(void){
  
  ll H,W,N,M;
  cin >> H >> W >> N >> M;

  int field[H+1][W+1];
  int field2[H+1][W+1];
  rep(i,H+1){
    rep(j,W+1){
      field[i][j] = 0;
      field2[i][j]=0;
    }
  }
  
  rep(i,N){//BOMB=N:1
    int A,B;
    cin >> A >> B;
    field[A][B] = 1;
  }
  rep(i,M){//WALL=M:2
    int C,D;
    cin>> C >> D;
    field[C][D] = 2;
  }
  
  
  vector<pair<int,int>> todo;
  for(int i=1; i<=H; i++){
    bool light = false;
    for(int j=1; j<=W; j++){
      if(field[i][j]==0){
        todo.pb(mp(i,j));
      }else if(field[i][j]==1){
        todo.pb(mp(i,j));
        light = true;
      }else if(field[i][j]==2){
        if(light){
          for(auto& k: todo){
            field2[k.first][k.second]+=3;
          }
        }
        todo.clear();
        light = false;
      }
      if(j==W){
        if(light){
          for(auto& k:todo){
            field2[k.first][k.second]+=3;
          }
        }
        todo.clear();
        light=false;
      }
    }
  }
  
  for(int i=1; i<=W; i++){
    bool light = false;
    for(int j=1; j<=H; j++){
      if(field[j][i]==0){
        todo.pb(mp(j,i));
      }else if(field[j][i]==1){
        todo.pb(mp(j,i));
        light = true;
      }else if(field[j][i]==2){
        if(light){
          for(auto& k: todo){
            field2[k.first][k.second]+=3;
          }
        }
        todo.clear();
        light = false;
      }
      if(j==H){
        if(light){
          for(auto& k:todo){
            field2[k.first][k.second]+=3;
          }
        }
        todo.clear();
        light=false;
      }
    }
  }
  
  ll ans=0;
  rep(i,H+1){
    //cout << "\n";
    rep(j,W+1){
      //cout << field2[i][j] << " " ;
      if(field2[i][j]>=3){
        ans++;
      }
    }
  }
  cout << ans;

  return 0;
}
#include<bits/stdc++.h>
#define forn(i, n) for(int i=0;i<(int)(n);i++)
#define for1(i, n) for(int i=1;i<=(int)(n);i++)
#define fore(i, l, r) for(int i=(int)(l);i<=(int)(r);i++)
#define ford(i, n) for(int i=(int)(n)-1;i>=0;i--)
#define pb push_back
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define endl "\n"
#define MAX 1000000007
using namespace std;
typedef int64_t ll;
typedef vector<int> vi;
typedef vector<int64_t> vll;
typedef vector<vi> vvi;
typedef vector<vll> vvll;

int main(int argc, char *argv[]){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.precision(10);
	cout << fixed;
	int n;
	string s;
	cin>>n>>s;
	int count=0;
	int a,t,g,c;
	for(int i=0;i<n-1;i++){
		a=0;t=0;g=0;c=0;
		for(int j=i;j<n;j++){
			if(s[j]=='A') ++a;
			if(s[j]=='T') ++t;
			if(s[j]=='G') ++g;
			if(s[j]=='C') ++c;
			count+=(a==t)&&(g==c);
		}
	}
	cout<<count;
	return 0;
}

