#include<bits/stdc++.h>
#define Tp template<typename Ty>
#define Ts template<typename Ty,typename... Ar>
#define Reg register
#define RI Reg int
#define Con const
#define CI Con int&
#define I inline
#define W while
#define N 200000
using namespace std;
int h,w,n,s[N+5];map<int,map<int,int> > p;
int main()
{
	RI i,t,x,y;for(scanf("%d%d%d",&h,&w,&n),i=1;i<=h;++i) s[i]=w+1;
	for(i=1;i<=n;++i) scanf("%d%d",&x,&y),s[x]=min(s[x],y);
	for(t=1,i=2;i<=h;++i) if(s[i]<=t) return printf("%d\n",i-1),0;else s[i]>t+1&&++t;
	return printf("%d\n",h),0;
}