#include <iostream>
#include <vector>
using namespace std;
int use(vector<vector<int>>& matrix, int N, int M)
{
    int max_count = 0, count = 0, max_x, max_y;
    for(int i = 0; i < N; i++)
    {
        for(int j = 0; j < M; j++)
        {
            count = 0;
            for(int k = i-1; k <= i+1; k++)
            {
                for(int l = j-1; l <= j+1; l++)
                {
                    if(k >= 0 && k < N && l >= 0 && l < M && matrix[k][l] > 0)
                    {
                        count ++;
                    }
                }
            }
            if(count > max_count)
            {
                max_count = count;
                max_x = i;
                max_y = j;
            }
        }
    }
    int deleteB = 0;
    for(int k = max_x-1; k <= max_x+1; k++)
    {
        for(int l = max_y-1; l <= max_y+1; l++)
        {
            if(k >= 0 && k < N && l >= 0 && l < M)
            {
                if(matrix[k][l] > 0)
                {
                    matrix[k][l]--;
                    deleteB ++;
                }
                
            }
        }
    }
    return deleteB;
}
int main()
{
    int N, M, K;
    while(cin >> N >> M >> K)
    {
        vector<vector<int>> matrix(N,vector<int>(M));
        //vector<vector<int>> xy(K,vector<int>(2));
        for(int i = 0; i < K; i++)
        {
            int x, y;
            cin >> x >> y;
            //xy[i] = {x,y};
            matrix[x-1][y-1]++;
        }
        int sum = use(matrix,N,M);
        sum += use(matrix,N,M);
        cout << sum << endl;


    }
    return 0;
}