#include "bits/stdc++.h"

using namespace std;

int MAX_N = 10000000;
vector<int> cnt(MAX_N, 0);

int main() {
  int r, s, p;
  cin >> r >> s >> p;
  for (int i = 0; i < p; i++) {
    int x, y;
    cin >> x >> y;
    int sum = r + 1 - x;
    if (y <= s) {
      sum += s + 1 - y;
    } else {
      sum += y - s;
    }
    //cerr << sum << endl;
    cnt[sum]++;
  }
  int ret = 0;
  for (int i = 1; i < MAX_N; i++) {
    if (cnt[i] == 0) continue;
    ret = i;
    if (cnt[i] == 1) {
      continue;
    }
    cnt[i + 1] += cnt[i] - 1;
  }
  cout << ret << endl;
}

