H,W,N = gets.split.map &:to_i
ws = {}
N.times {
  x,y = gets.split.map &:to_i
  ws[x] ||= {}
  ws[x][y] = 1
}

m = 0; a,b = 1,1
#p ws
(H+W).times {
  #p [a,b]
  if W == a || (ws[a+1] || {})[b]
    m += 1
    break
  end
  a += 1
  m += 1
  if b < H && !(ws[a] || {})[b+1]
    b += 1
  end
}
p m