#include <bits/stdc++.h>
using namespace std;
#define int long long
vector<int>bit(200001);
void update(int x, int val){
	for(int a = x; a<=200000; a+=a&-a){
		bit[a]+=val;
	}
}
int query(int x){
	int sum = 0;
	for(int a = x; a>0; a-=a&-a){
		sum+=bit[a];
	}
	return sum;
}
signed main(){
	cin.tie(nullptr)->sync_with_stdio(false);
	int r,c,m;
	cin >> r >> c >> m;
	vector<int>mnv(c+1, r+1);
	vector<int>mnh(r+1, c+1);
	for(int i = 0; i<m; i++){
		int x,y;
		cin >> x >> y;
		mnv[y] = min(mnv[y],x);
		mnh[x] = min(mnh[x],y);
	}
	int ans = 0;
	set<pair<int,int>>s;
	for(int i = 2; i<mnh[1]; i++){
		int val = mnv[i]-1;
		ans+=val;
		s.insert({mnv[i],i});
	}
	for(int i = mnh[1]; i<=c; i++){
		update(i,1);
	}
	//cout << ans << "\n";
	update(1,1);
	int cur = 1;
	for(int i = 2; i<mnv[1]; i++){
		if(s.size()>0)
		while(s.size()>0&&(*s.begin()).first+1<=i){
			update((*s.begin()).second,1);
			s.erase(s.begin());
		}
		ans+=query(mnh[i]-1);
		//cout << ans << "\n";
	}
	cout << ans+1 << "\n";
	return 0;
}
/* 	author : sgupta_2001 	*/

#include<bits/stdc++.h>

using namespace std;

using db = double;
using ll = long long;
using ld = long double;
using ull = unsigned long long;

//containers
#define sz(x) int((x).size())
#define bg(x) begin(x)
#define all(x) bg(x), end(x)
#define rall(x) x.rbegin(), x.rend() 
#define sor(x) sort(all(x)) 
#define rsz resize
#define ins insert 
#define ft front()
#define bk back()
#define pb push_back
#define eb emplace_back 
#define pf push_front

//pairs
#define mp make_pair
#define ff first
#define ss second

//loops
#define rep(i, a, b) for(int i = a; i < b; ++i)
#define per(i, a, b) for(int i = b - 1; i >= a; --i)
#define each(x, a) for(auto &x : a)

//popular constants
const int mod = 1e9 + 7; //998244353;
const ll inf = 1e18;
const ld pie = acos((ld) - 1);

//grid problems
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

//modulo operations
ll mod_add(ll a, ll b, ll m) {a = a % m; b = b % m; return (((a + b) % m) + m) % m;}
ll mod_mul(ll a, ll b, ll m) {a = a % m; b = b % m; return (((a * b) % m) + m) % m;}
ll mod_sub(ll a, ll b, ll m) {a = a % m; b = b % m; return (((a - b) % m) + m) % m;}

#ifdef SGUPTA_2001
#define deb(x) cerr<< #x <<" "; __print(x); cerr<<'\n';
#else
#define deb(x);
#endif

//debug containers
template<class T> void __print(T x) {cerr<<x;}
template<class T, class U> void __print(pair<T,U> p) {cerr<<"{"<<p.ff<<", "<<p.ss<<"}";}
template<class T> void __print(vector<T> arr) { cerr<<"[ "; for(auto x:arr) { __print(x);cerr<<" "; } cerr<<"]"; }
template<class T> void __print(set<T> st) { cerr<<"{ "; for(auto x:st) { __print(x); cerr<<" "; } cerr<<"}";}
template<class T, class U> void __print(vector<pair<T,U>> arr) { cerr<<"[ "; for(auto x:arr) {__print(x);cerr<<", ";}cerr<<"]";}
template<class T, class U> void __print(unordered_map<T,U> arr) { cerr<<"{ "; for(auto x:arr) {__print(x);cerr<<", ";}cerr<<"}";}
template<class T, class U> void __print(map<T,U> arr) { cerr<<"{ "; for(auto x:arr) {__print(x);cerr<<", ";}cerr<<"}";}
template<typename... T> void read(T&... args) { ((cin>>args),...);}
template<typename... T> void write(T&&... args){((cout<<args<<" "),...);cout<<'\n';}


void solve() {

	int N, A, B;
	scanf("%d%d%d", &N, &A, &B);

	printf("%d\n", N - A + B);


	return;
}


int main() {

	#ifdef SGUPTA_2001
		freopen("input.txt", "r", stdin);
		freopen("error.txt", "w", stderr);
	#endif

	auto start = std::chrono::high_resolution_clock::now();

	int t;
	t=1;
	while(t--) solve();

  auto stop = std::chrono::high_resolution_clock::now(); 
  auto duration = std::chrono::duration_cast<std::chrono::nanoseconds>(stop - start);
  // cerr << "Time taken : " << ((long double)duration.count())/((long double) 1e9) <<"s "<< '\n';

	 /* 
	 		STUFF TO LOOK:	
			1. Check the constraints
			2. Corner cases(n == 0 || n == 1)
			3. Variables in loops
			4. Make sure two ints aren’t multiplied to get a long long 
	*/  

	return 0;
}
