#include<bits/stdc++.h>
typedef long long ll;
using namespace std;

struct tr{
    ll x,y;
};

bool operator < (tr a, tr b){
    return a.x < b.x;
}

ll h,w,n;
vector<tr> a;

main(){
    cin >> h >> w >> n;
    ll f1,f2;
    a.resize(n);
    for(int i=0;i<n;++i){
        cin >> f1 >> f2;
        a[i] = {f1,f2};
    }
    sort(a.begin(),a.end());

    set<pair<ll,ll>> no_points;
    ll ans = h;
    for(int i=0;i<n;++i){
        if(no_points.count({a[i].x,a[i].y}) == 0 && a[i].x-1>=a[i].y){
            ans = a[i].x-1;
            //cout << "ans_p" << a[i].x << ' ' << a[i].y << "\n";
            break;
        }
        else{
            for(int j=0;j<min(h-a[i].x,w-a[i].y);++j){
                //cout << a[i].x+j+1 << ' ' << a[i].y+j << "\n";
                no_points.insert({a[i].x+j+1,a[i].y+j});
            }
        }
    }

    cout << ans;

}
