H, W, N = gets.split.map(&:to_i)
w2h = Array.new(W+1){[]}
N.times do |i|
    x, y = gets.split.map(&:to_i)
    w2h[y].push(x)
end

ans = H
loss = 0
(1..W).each do |w|
    w2h[w].sort.each do |h|
        if h-loss == w
            loss += 1
        elsif h-loss > w
            ans = h-1 if ans > h-1
            break
        end
    end
end
puts ans