#include<bits/stdc++.h>
using namespace std;
#define arep(i,x,n) for(int i=int(x);i<(int)(n);i++)
#define rep(i,n) for(ll i = 0;i < (ll)n;++i)
#define rrep(i,n) for(int i=int(n-1);i>=0;i--)
#define fs first
#define sc second
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define coy cout<<"Yes"<<endl
#define con cout<<"No"<<endl
#define pi 3.141592653589793
#define eps 0.00000001
#define INF 1e9+7
#define LINF (ll)1e18+10  
using ll = long long;

using P = pair<ll,ll>;
using fP = pair<double, double>;
using PPI = pair<P, int>;
using PIP = pair<int, P>;
using Ps = pair<int, string>;

using vi = vector<int>;
using vl = vector<ll>;
using vc = vector<char>;
using vd = vector<double>;
using vs = vector<string>;
using vp = vector<P>;
using vb = vector<bool>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
using vvd = vector<vector<double>>;
using vvc = vector<vector<char>>;
using vvp = vector<vector<P>>;
using vvb = vector<vector<bool>>;
template <typename T>
bool chmax(T& a, const T b) { if (a < b) { a = b; return true; } return false; }
template <typename T>
bool chmin(T& a, const T b) { if (a > b) { a = b; return true; } return false; }

//const ll mod=998244353;
const ll mod = 1e9 + 7;
const ll MAX = 100;
template <typename T>
T abs(T a) { if (a < 0)return -a; else return a; }//2020/09/30 stdlib has abs(long) abs(long long) error
//////////////////////////////////////
class UnionFind {
public:
    vector <ll> par; // 各元の親を表す配列
    vector <ll> siz; // 素集合のサイズを表す配列(1 で初期化)
    
    // Constructor
    UnionFind(ll sz_): par(sz_), siz(sz_, 1LL) {
        for (ll i = 0; i < sz_; ++i) par[i] = i; // 初期では親は自分自身
    }
    void init(ll sz_=1) {
        par.resize(sz_);
        siz.assign(sz_, 1LL);  // resize だとなぜか初期化されなかった
        for (ll i = 0; i < sz_; ++i) par[i] = i; // 初期では親は自分自身
    }

    // Member Function
    // Find
    ll root(ll x) { // 根の検索
        while (par[x] != x) {
         x = par[x] = par[par[x]]; // x の親の親を x の親とする
        }
        return x;
    }

    // Union(Unite, Merge)
    bool merge(ll x, ll y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        // merge technique（データ構造をマージするテク．小を大にくっつける）
        if (siz[x] < siz[y]) swap(x, y);
        siz[x] += siz[y];
        par[y] = x;
        return true;
    }

    bool issame(ll x, ll y) { // 連結判定
        return root(x) == root(y);
    }

    ll size(ll x) { // 素集合のサイズ
        return siz[root(x)];
    }
};

int main(){
    int n;
    cin>>n;
    vi a(n);
    int ans=0;
    rep(i,n)cin>>a[i];
    UnionFind uf(200005);
    if(n==1){
        cout<<0<<endl;
        return 0;
    }
    uf.init(200005);
    {
        rep(i,n/2+1){
            int l=i;
            int r=n-1-i;
            if(uf.issame(a[l],a[r]))continue;
            uf.merge(a[l],a[r]);
            ans++;
        }
    }
    cout<<ans<<endl;
    return 0;
}
#include <algorithm>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
using ll = long long;
using P = pair<int, int>;
const int MX = 1505;

bool visited[MX][MX];
bool memo[MX][MX];
bool light[MX][MX];
bool wall[MX][MX];
bool ok[MX][MX];
int di[] = {1, 0, -1, 0};
int dj[] = {0, -1, 0, 1};
int h, w;

bool f(int dir, int i, int j) {
  if (i < 0 || i >= h || j < 0 || j >= w) return false;
  if (light[i][j]) return true;
  if (visited[i][j]) return memo[i][j];
  if (wall[i][j]) return false;
  visited[i][j] = true;

  return memo[i][j] = f(dir, i + di[dir], j + dj[dir]);
};

int main() {
  int n, m;
  cin >> h >> w >> n >> m;

  rep(i, n) {
    int a, b;
    cin >> a >> b;
    --a;
    --b;
    light[a][b] = true;
  }
  rep(i, m) {
    int a, b;
    cin >> a >> b;
    --a;
    --b;
    wall[a][b] = true;
  }
  rep(dir, 4) {
    rep(i, h) rep(j, w) visited[i][j] = false;
    rep(i, h) rep(j, w) if (f(dir, i, j)) ok[i][j] = true;
  }
  int ans = 0;
  rep(i, h) {
    rep(j, w) {
      if (ok[i][j]) ans++;
    }
  }
  cout << ans;

  return 0;
}
