#import numpy as np
import collections
#import math




#f = open('./input_E.txt')
#
#H,W,M=map(int, f.readline().split())
#bakuha = []
#bakuha_H=[]
#bakuha_W=[]
#for i in range(M):
#    hh,ww=map(int, f.readline().split())
#    bakuha_H.append(hh)
#    bakuha_W.append(ww)
#    bakuha.append([hh,ww])




H,W,M=map(int, input().split())
bakuha = []
bakuha_H=[]
bakuha_W=[]
for i in range(M):
    hh,ww=map(int, input().split())
    bakuha_H.append(hh)
    bakuha_W.append(ww)
    bakuha.append([hh,ww])





count_H = collections.Counter(bakuha_H)
H_most = count_H.most_common()
H_most_num = H_most[0][1]

#H_only_most = [x for x in H_most if x[1]==H_most_num]
#H_kouho = [x[0] for x in H_only_most]

H_kouho = [x[0] for x in H_most if x[1]==H_most_num]


count_W = collections.Counter(bakuha_W)
W_most = count_W.most_common()
W_most_num = W_most[0][1]

#W_only_most = [x for x in W_most if x[1]==W_most_num]
#W_kouho = [x[0] for x in W_only_most]
W_kouho = [x[0] for x in W_most if x[1]==W_most_num]

ans = H_most_num + W_most_num

#マイナス1するかどうか
ans_minus = True

len_H_kouho=len(H_kouho)
len_W_kouho=len(W_kouho)
num_kouho = len_H_kouho*len_W_kouho

bakuha_1d = [W * (x[0]-1) + x[1] for x in bakuha]
bakuha_1d.sort(reverse=True)
bakuha_1d_max = bakuha_1d[0]
bakuha_1d_min = bakuha_1d[-1]

#print(bakuha_1d)

if num_kouho <= M:
    kouho_1d = []
    for h_k in H_kouho:
        for w_k in W_kouho:
            kouho_1d.append(W*(h_k-1)+w_k)
    kouho_1d.sort()
    kouho_1d_min = kouho_1d[0]
    kouho_1d_max = kouho_1d[-1]
    
#    print(kouho_1d)    
    
    if kouho_1d_max <= bakuha_1d_max and kouho_1d_min >= bakuha_1d_min:
        for k1 in kouho_1d:
            tuzuku = True
            while tuzuku:
                b1_0 = bakuha_1d.pop()
#                print(k1,b1_0)
                if b1_0 >= k1:
                    tuzuku = False
                    if b1_0 != k1:
                        ans_minus = False
    else:
        ans_minus = False
#    for i in range(M):
#        b1_0 = bakuha_1d.pop(0)
        
        
        
else:
    ans_minus = False
#
if ans_minus:
    ans-=1
    

print(ans)

### FIXED CODE ###

#import numpy as np
import collections
#import math




#f = open('./input_E.txt')
#
#H,W,M=map(int, f.readline().split())
#bakuha = []
#bakuha_H=[]
#bakuha_W=[]
#for i in range(M):
#    hh,ww=map(int, f.readline().split())
#    bakuha_H.append(hh)
#    bakuha_W.append(ww)
#    bakuha.append([hh,ww])




H,W,M=map(int, input().split())
bakuha = []
bakuha_H=[]
bakuha_W=[]
for i in range(M):
    hh,ww=map(int, input().split())
    bakuha_H.append(hh)
    bakuha_W.append(ww)
    bakuha.append([hh,ww])





count_H = collections.Counter(bakuha_H)
H_most = count_H.most_common()
H_most_num = H_most[0][1]

#H_only_most = [x for x in H_most if x[1]==H_most_num]
#H_kouho = [x[0] for x in H_only_most]

H_kouho = [x[0] for x in H_most if x[1]==H_most_num]


count_W = collections.Counter(bakuha_W)
W_most = count_W.most_common()
W_most_num = W_most[0][1]

#W_only_most = [x for x in W_most if x[1]==W_most_num]
#W_kouho = [x[0] for x in W_only_most]
W_kouho = [x[0] for x in W_most if x[1]==W_most_num]

ans = H_most_num + W_most_num

#マイナス1するかどうか
ans_minus = True

len_H_kouho=len(H_kouho)
len_W_kouho=len(W_kouho)
num_kouho = len_H_kouho*len_W_kouho

bakuha_1d = [W * (x[0]-1) + x[1] for x in bakuha]
bakuha_1d.sort(reverse=True)
bakuha_1d_max = bakuha_1d[0]
bakuha_1d_min = bakuha_1d[-1]

#print(bakuha_1d)

if num_kouho <= M:
    kouho_1d = []
    for h_k in H_kouho:
        for w_k in W_kouho:
            kouho_1d.append(W*(h_k-1)+w_k)
    kouho_1d.sort()
    kouho_1d_min = kouho_1d[0]
    kouho_1d_max = kouho_1d[-1]
    
#    print(kouho_1d)    
    
    if kouho_1d_max <= bakuha_1d_max and kouho_1d_min >= bakuha_1d_min:
        b1_0 = bakuha_1d_min
        for_break=False
        for k1 in kouho_1d:
#            if k1 >= b1_0:
            tuzuku = True
            while tuzuku:
                b1_0 = bakuha_1d.pop()
#                print(k1,b1_0)
                if b1_0 >= k1:
                    tuzuku = False
                    if b1_0 != k1:
                        ans_minus = False
                        for_break=True
            if for_break:
                break
    else:
        ans_minus = False
#    for i in range(M):
#        b1_0 = bakuha_1d.pop(0)
        
        
        
else:
    ans_minus = False
#
#print(ans_minus)
if ans_minus:
    ans-=1
    

print(ans)