#include <iostream>
#include <map>
#include <cmath>

using namespace std;

int r, s, p;

int main() {
  while (cin >> r >> s >> p) {
    map<int, int> cnt;
    for (int i = 0; i < p; ++i) {
      int x, y;
      cin >> y >> x;
      int xx;
      if (x > s) {
        xx = x - s;
      } else {
        xx = s - x + 1;
      }
      int d = (r - (y-1)) + xx;
      ++cnt[d];
    }
    int now = 0;
    for (auto iter : cnt) {
      if (now < iter.first) {
        now = iter.first + iter.second - 1;
      } else {
        now = now + iter.second;
      }
    }
    cout << now << endl;
  }
}

