#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<set>
#include<queue>
#include<stack>
#include<bitset>
#include<functional>
#include<map>
#include<unordered_set>
using namespace std;
/*int p = 998244353;*/
int p = 1000000007;
#define int long long
#define vel vector<long long>
#define vvel vector<vel>
#define rep(i,n) for(int i=0;i<n;i++)
#define sor(v) sort(v.begin(),v.end())
#define mmax(a,b) a=max(a,b)
#define mmin(a,b) a=min(a,b)
#define mkp make_pair
#define pin pair<int,int>
#define qin pair<int,pin>
#define V vector
#define Endl endl
#define veb vector<bool>
#define rev(s) reverse(s.begin(),s.end())
signed main(){
	int w, h, n; cin >> w >> h >> n;
	if (h == 1 || w == 1) { cout << 0 << endl; return 0; }
	vvel pot(w);
	rep(i, n) {
		int x, y; cin >> x >> y;
		pot[x].push_back(y);
	}
	int ans = w-1;
	vel maxi(w,0); maxi[w - 1] = 0;
	for (int i = w - 2; i >= 0; i--) {
		maxi[i] = maxi[i + 1];
		for (auto x : pot[i + 1]) {
			mmax(maxi[i], x);
		}
		mmin(ans, maxi[i] + i);
	}
	cout << ans << endl;
	return 0;
}
