#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
using namespace std;
set<int>ds[201010];
int main()
{
	int mx, my,num;
	scanf("%d%d%d", &mx, &my, &num);
	for (int i = 0; i < num; i++)
	{
		int za, zb;
		scanf("%d%d", &za, &zb);
		za--, zb--;
		ds[zb].insert(za);
	}
	for (int i = 0; i <= my; i++)ds[i].insert(mx);
	for (int i = 0; i <= mx; i++)ds[my].insert(i);
	int mini = 1000000000;
	int nx = 0;
	for (int ny = 0; ny < my; ny++)
	{
		nx++;
		int t = *(ds[ny].lower_bound(nx));
		mini = min(mini, t);
		if (t == nx)break;
		for (;;)
		{
			if (nx == mx)goto l01;
			if (ds[ny + 1].find(nx) == ds[ny + 1].end())break;
			else nx++;
		}
	}
l01:;
	printf("%d\n", mini);
}