#include<bits/stdc++.h>
#define ll long long
#define mp make_pair
#define f(i,n) for(int i=0;i<n;i++)
#define F first
#define S second
#define pb push_back
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
using namespace std;
void test(){
ll h,w,m;
cin>>h>>w>>m;
vector<pair<ll,ll> > row,col;
f(i,m){
ll a,b;
cin>>a>>b;
a--,b--;
row.pb({a,b});
col.pb({b,a});
}
if(m==0){
cout<<h*w<<"\n";
return ;
}
sort(row.begin(),row.end());
ll r_res[h], c_res[w];
f(i,h)r_res[i]=w+1;
f(i,w)c_res[i]=h+1;
f(i,m){
r_res[row[i].F] = min(r_res[row[i].F],row[i].S+1);
c_res[col[i].F] = min(c_res[col[i].F],col[i].S+1);
}
ll res = 0;
f(i,c_res[0]-1){
res = res + r_res[i]-1;
}
f(i,r_res[0]-1){
res = res + c_res[i]-1;
}
// remove repeated cases
ordered_set st;
int in = 0;
f(i,c_res[0]-1){
while(in<m and row[in].F==i){
st.insert((int)row[in].S);
in++;
}
// out of these columns find no's which are less than to r_res[i]-1, r_res[0]-1
ll rem = st.order_of_key(min(r_res[i]-1,r_res[0]-1));
res = res - (min(r_res[i]-1,r_res[0]-1)-rem);
}
cout<<res<<"\n";
}
int main(){
std::ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int tests=1;
// cin>>tests;
while(tests--){
test();
}
}
I2luY2x1ZGU8Yml0cy9zdGRjKysuaD4KI2RlZmluZSBsbCBsb25nIGxvbmcgCiNkZWZpbmUgbXAgbWFrZV9wYWlyIAojZGVmaW5lIGYoaSxuKSBmb3IoaW50IGk9MDtpPG47aSsrKSAKI2RlZmluZSBGIGZpcnN0IAojZGVmaW5lIFMgc2Vjb25kIAojZGVmaW5lIHBiIHB1c2hfYmFjayAKI2luY2x1ZGUgPGV4dC9wYl9kcy9hc3NvY19jb250YWluZXIuaHBwPi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