暴力水 -_-||
#include<stdio.h>
#include<algorithm>
#include<iostream>
#include<string.h>
#include<stdlib.h>
#include<queue>
#include<vector>
#include<math.h>
#include<stack>
using namespace std;
const int MAX = 5000+10;
const double eps = 1e-10;
const double PI = acos(-1.0);
bool maps[MAX][MAX];
int c, r, n, maxx;
struct node
{
int x, y;
} lxt[MAX];
bool cmp(node a, node b)
{
if(a.x!=b.x)return a.x<b.x;
return a.y<b.y;
}
bool check(int x, int y)
{
if(x>=1&&x<=r&&y>=1&&y<=c)return 1;
return 0;
}
int solve(int x, int y, int dx, int dy)
{
int ans = 2;
while(1)
{
x+=dx;
y+=dy;
if(!check(x, y))break;
if(maps[x][y])ans++;
else return 0;
}
return ans;
}
int main()
{
scanf("%d%d%d", &r, &c, &n);
memset(maps, 0, sizeof(maps));
for(int i =0; i<n; ++i)
{
scanf("%d%d", &lxt[i].x, &lxt[i].y);
maps[lxt[i].x][lxt[i].y] = 1;
}
sort(lxt, lxt+n, cmp);
maxx = 2;
for(int i =0; i<n-1; ++i)
{
for(int j = i+1; j<n; ++j)
{
int dx = lxt[j].x-lxt[i].x;
int dy = lxt[j].y-lxt[i].y;
if(check(lxt[i].x-dx, lxt[i].y-dy))continue;
maxx = max(maxx, solve(lxt[j].x, lxt[j].y, dx, dy));
}
}
if(maxx==2)cout<<0<<endl;
else cout<<maxx<<endl;
return 0;
}