import std;
void main(string[] args){ if(args.length > 1) if(args[1] == "-debug") DEBUG = 1; solve(); } bool DEBUG = 0; 
void log(A ...)(lazy A a){ if(DEBUG) print(a); }
void print(){ writeln(""); } void print(T)(T t){ writeln(t); } void print(T, A ...)(T t, A a){ std.stdio.write(t, " "), print(a); }
string unsplit(T)(T xs){ return xs.array.to!(string[]).join(" "); }
string scan(){ static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res; }
T scan(T)(){ return scan.to!T; } T[] scan(T)(int n){ return n.iota.map!(i => scan!T()).array; }
T lowerTo(T)(ref T x, T y){ if(x > y) x = y; return x; } T raiseTo(T)(ref T x, T y){ if(x < y) x = y; return x; }

// ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- //

void solve(){
  int h = scan!int, w = scan!int, n = scan!int;
  U[] us;
  foreach(_; 0 .. n){
    int x = scan!int - 1, y = scan!int - 1;
    us ~= U(x, y);
  }
  foreach(y; 0 .. w) us ~= U(h, y);
  us.sort!"a.isLess(b)"();
  log("us:", us);
  
  int cnt = 0;
  foreach(u; us){
    log("u:", u, "x:", u.x, "y:", u.y, "cnt:", cnt);
    if(u.y > u.x - cnt) continue;
    else if(u.y == u.x - cnt) cnt += 1;
    else{
      u.x.writeln;
      return;
    }
  }
}
struct U{
  int x, y;
  bool isLess(U v){ return (x != v.x)? (x < v.x): (y < v.y); }
}