#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i ++)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i ++)
#define MP make_pair

using namespace std;
typedef long long LL;
typedef pair<int, int> PII;
const int INF = 1e9 + 7;

vector<int> hv[200005];
int h, w, n;

int main()
{
	scanf("%d%d%d", &h, &w, &n);
	rep(i, n) {
		int x, y;
		scanf("%d%d" ,&x, &y);
		hv[x].push_back(y);
	}
	int clen = 1;
	for(int i = 2; i <= h; i ++) {
		rep(j, hv[i].size()) if(hv[i][j] <= clen) {
			printf("%d\n", i - 1);
			return 0;
		}
		clen ++;
		rep(j, hv[i].size()) if(hv[i][j] == clen) {
			clen --;
			break;
		}
	}
	printf("%d\n", h);
	return 0;
}