https://www.acmicpc.net/problem/1743
from collections import deque
import sys
input = sys.stdin.readline
dx = [0, 0, -1, 1]
dy = [-1, 1, 0, 0]
def bfs(x, y):
que = deque()
road[x][y] = 1
que.append((x, y))
cnt = 1
visited[x][y] = True
while que:
x, y = que.popleft()
for i in range(4):
nx = x + dx[i]
ny = y + dy[i]
if 0 <= nx < n and 0 <= ny < m and road[nx][ny] == -1 and visited[nx][ny] == False:
cnt += 1
road[nx][ny] = 1
visited[nx][ny] = True
que.append((nx, ny))
return cnt
n, m, k = map(int, input().split())
road = [[0 for _ in range(m)]for _ in range(n)]
visited = [[False for i in range(m)]for _ in range(n)]
for _ in range(k):
x, y = map(int, input().split())
x -= 1
y -= 1
road[x][y] = -1
res = 0
for i in range(n):
for j in range(m):
if road[i][j] == -1 and visited[i][j] == False:
res = max(res, bfs(i, j))
print(res)