//YashS
#include <bits/stdc++.h>
using namespace std;
#define test              int T;cin>>T;while(T--)
#define int               long long
#define pb                push_back
#define all(x)            (x).begin(),(x).end()
#define sz(x)             (int)((x).size())
#define fr                first
#define sc                second
#define minf              LONG_LONG_MIN
#define inf              LONG_LONG_MAX
#define pii               pair<int,int>
#define rep(i,a,b)        for(int i=a;i<b;i++)
#define mem1(x, arr)           memset((arr),x,sizeof((arr))
#define pVec(v)           for(auto e:v)cout<<e<<" ";cout<<"\n"
const int MOD = 1e9 + 7;
const int N = 1e5 + 7;

void init_code() {
#ifndef ONLINE_JUDGE
	freopen("inputf.txt", "r", stdin);
	freopen("outputf.txt", "w", stdout);
#endif // ONLINE_JUDGE
}
void yash()
{
	int n;
	cin >> n;
	vector<int> a(n), b(n), c(n), freq(n + 1);
	for (int &x : a)cin >> x;
	for (int &x : b)cin >> x;
	for (int &x : c) {cin >> x; x = b[x - 1]; freq[x]++;}
	int ans = 0;
	for (int x : a)ans += freq[x];
	cout << ans << "\n";

}

signed main()
{
	init_code();
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	//test
	yash();
	return 0;
}
#include <bits/stdc++.h>
// #include <atcoder/all>
// #include "icld.cpp"
using namespace std;
using ll = long long int;
using pii = pair<int,int>;
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vector<int>>;
using ss = string;
using db = double;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
//#define pi 3.14159265358979
#define rep(i,s,n) for(int i=(s);i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define ci(x) cin >> x
#define cii(x) int x;cin >> x
#define cci(x,y) int x,y;cin >> x >> y
#define co(x) cout << x << endl

int main(){
  cci(h,w);
  cci(n,m);

  vvi v(h+2,vi(w+2,-1));
  rep(i,1,h+1)rep(j,1,w+1)v[i][j]=0;

  vector<pii> el(n);
  rep(i,0,n){
    cci(x,y);
    el[i]=make_pair(x,y);
  } 
  rep(i,0,m){
    cci(x,y);
    v[x][y]=-1;
  }

  vvi vx=v,vy=v;
  rep(i,0,n){
    int x,y;
    tie(x,y)=el[i];
    int nx=x,ny=y;
    while(v[--nx][y]!=-1);
    while(v[x][--ny]!=-1);
    vx[nx+1][y]=1;
    vy[x][ny+1]=1;
  }

  rep(i,1,h+1){
    int now=0;
    rep(j,1,w+1){
      int y=vy[i][j];
      if(y==1)now=1;
      else if(y==-1)now=0;
      if(now)v[i][j]=1;
    }
  }
  rep(i,1,w+1){
    int now=0;
    rep(j,1,h+1){
      int x=vx[j][i];
      if(x==1)now=1;
      else if(x==-1)now=0;
      if(now)v[j][i]=1;
    }
  }

  int ans=0;
  rep(i,1,h+1)rep(j,1,w+1)ans+=(v[i][j]==1);
  co(ans);
}