import collections
import copy

a = list(map(int,input().split()))
c = []
d = []
for i in range(a[2]):
    b = list(map(int,input().split()))
    c.append(b[0])
    d.append(b[1])

ans1 = 0
ans2 = 0

cp = copy.copy(c)
dp = copy.copy(d)

e = collections.Counter(c)
f = collections.Counter(d)
g = e.most_common()[0][0]
gc = e.most_common()[0][1]
h = f.most_common()[0][0]
hc = f.most_common()[0][1]
ans1 += gc
ans2 += hc
for i in range(a[2]):
    if cp[i] == g:
        d[i] = -1
    if dp[i] == h:
        c[i] = -1
e = collections.Counter(c)
f = collections.Counter(d)
g = e.most_common()[0][0]
gc = e.most_common()[0][1]
h = f.most_common()[0][0]
hc = f.most_common()[0][1]

if g == -1:
    if gc == a[2]:
        gc = 0
    else:
        g = e.most_common()[1][0]
        gc = e.most_common()[1][1]
if h == -1:
    if hc == a[2]:
        hc = 0
    else:
        h = f.most_common()[1][0]
        hc = f.most_common()[1][1]

ans1 += hc
ans2 += gc
if ans1 > ans2:
    print(str(ans1))
else:
    print(str(ans2)) import collections collections import copy copy a = list(map(int,input().split())) a list(map(int,input().split())) list map(int,input().split()) map int input().split() ().split () input split c = [] c [] d = [] d [] for i in range(a[2]):
    b = list(map(int,input().split()))
    c.append(b[0])
    d.append(b[1]) i range(a[2]) range a[2] a 2 b = list(map(int,input().split())) b list(map(int,input().split())) list map(int,input().split()) map int input().split() ().split () input split c.append(b[0]) c.append c append b[0] b 0 d.append(b[1]) d.append d append b[1] b 1 ans1 = 0 ans1 0 ans2 = 0 ans2 0 cp = copy.copy(c) cp copy.copy(c) copy.copy copy copy c dp = copy.copy(d) dp copy.copy(d) copy.copy copy copy d e = collections.Counter(c) e collections.Counter(c) collections.Counter collections Counter c f = collections.Counter(d) f collections.Counter(d) collections.Counter collections Counter d g = e.most_common()[0][0] g e.most_common()[0][0] [0] e.most_common() e.most_common e most_common 0 0 gc = e.most_common()[0][1] gc e.most_common()[0][1] [0] e.most_common() e.most_common e most_common 0 1 h = f.most_common()[0][0] h f.most_common()[0][0] [0] f.most_common() f.most_common f most_common 0 0 hc = f.most_common()[0][1] hc f.most_common()[0][1] [0] f.most_common() f.most_common f most_common 0 1 ans1 += gc ans1 gc ans2 += hc ans2 hc for i in range(a[2]):
    if cp[i] == g:
        d[i] = -1
    if dp[i] == h:
        c[i] = -1 i range(a[2]) range a[2] a 2 if cp[i] == g:
        d[i] = -1
     cp[i] == g cp[i] cp i g d[i] = -1 d[i] d i -1 if dp[i] == h:
        c[i] = -1 dp[i] == h dp[i] dp i h c[i] = -1 c[i] c i -1 e = collections.Counter(c) e collections.Counter(c) collections.Counter collections Counter c f = collections.Counter(d) f collections.Counter(d) collections.Counter collections Counter d g = e.most_common()[0][0] g e.most_common()[0][0] [0] e.most_common() e.most_common e most_common 0 0 gc = e.most_common()[0][1] gc e.most_common()[0][1] [0] e.most_common() e.most_common e most_common 0 1 h = f.most_common()[0][0] h f.most_common()[0][0] [0] f.most_common() f.most_common f most_common 0 0 hc = f.most_common()[0][1] hc f.most_common()[0][1] [0] f.most_common() f.most_common f most_common 0 1 if g == -1:
    if gc == a[2]:
        gc = 0
    else:
        g = e.most_common()[1][0]
        gc = e.most_common()[1][1] g == -1 g -1 if gc == a[2]:
        gc = 0
    else:
        g = e.most_common()[1][0]
        gc = e.most_common()[1][1] gc == a[2] gc a[2] a 2 gc = 0 gc 0 g = e.most_common()[1][0] g e.most_common()[1][0] [1] e.most_common() e.most_common e most_common 1 0 gc = e.most_common()[1][1] gc e.most_common()[1][1] [1] e.most_common() e.most_common e most_common 1 1 if h == -1:
    if hc == a[2]:
        hc = 0
    else:
        h = f.most_common()[1][0]
        hc = f.most_common()[1][1] h == -1 h -1 if hc == a[2]:
        hc = 0
    else:
        h = f.most_common()[1][0]
        hc = f.most_common()[1][1] hc == a[2] hc a[2] a 2 hc = 0 hc 0 h = f.most_common()[1][0] h f.most_common()[1][0] [1] f.most_common() f.most_common f most_common 1 0 hc = f.most_common()[1][1] hc f.most_common()[1][1] [1] f.most_common() f.most_common f most_common 1 1 ans1 += hc ans1 hc ans2 += gc ans2 gc if ans1 > ans2:
    print(str(ans1))
else:
    print(str(ans2)) ans1 > ans2 ans1 ans2 print(str(ans1)) print str(ans1) str ans1 print(str(ans2)) print str(ans2) str ans2 d = [] [] d gc = e.most_common()[0][1] e.most_common()[0][1] gc h = f.most_common()[0][0] f.most_common()[0][0] h h = f.most_common()[0][0] f.most_common()[0][0] h ans1 += gc gc ans1 f = collections.Counter(d) collections.Counter(d) f b = list(map(int,input().split())) list(map(int,input().split())) b gc = e.most_common()[1][1] e.most_common()[1][1] gc c = [] [] c e = collections.Counter(c) collections.Counter(c) e ans2 += gc gc ans2 gc = 0 0 gc ans2 += hc hc ans2 a = list(map(int,input().split())) list(map(int,input().split())) a ans2 = 0 0 ans2 hc = 0 0 hc cp = copy.copy(c) copy.copy(c) cp g = e.most_common()[0][0] e.most_common()[0][0] g ans1 += hc hc ans1 hc = f.most_common()[0][1] f.most_common()[0][1] hc h = f.most_common()[1][0] f.most_common()[1][0] h hc = f.most_common()[0][1] f.most_common()[0][1] hc dp = copy.copy(d) copy.copy(d) dp hc = f.most_common()[1][1] f.most_common()[1][1] hc g = e.most_common()[0][0] e.most_common()[0][0] g f = collections.Counter(d) collections.Counter(d) f g = e.most_common()[1][0] e.most_common()[1][0] g ans1 = 0 0 ans1 gc = e.most_common()[0][1] e.most_common()[0][1] gc e = collections.Counter(c) collections.Counter(c) e
import collections
import copy

a = list(map(int,input().split()))
c = []
d = []
for i in range(a[2]):
    b = list(map(int,input().split()))
    c.append(b[0])
    d.append(b[1])

ans1 = 0
ans2 = 0

cp = copy.copy(c)
dp = copy.copy(d)

e = collections.Counter(c)
f = collections.Counter(d)
g = e.most_common()[0][0]
gc = e.most_common()[0][1]
h = f.most_common()[0][0]
hc = f.most_common()[0][1]
ans1 += gc
ans2 += hc
for i in range(a[2]):
    if cp[i] == g:
        d[i] = -1
    if dp[i] == h:
        c[i] = -1
e = collections.Counter(c)
f = collections.Counter(d)
g = e.most_common()[0][0]
gc = e.most_common()[0][1]
h = f.most_common()[0][0]
hc = f.most_common()[0][1]

if g == -1:
    if gc == a[2]:
        gc = 0
    else:
        g = e.most_common()[1][0]
        gc = e.most_common()[1][1]
if h == -1:
    if hc == a[2]:
        hc = 0
    else:
        h = f.most_common()[1][0]
        hc = f.most_common()[1][1]

ans1 += hc
ans2 += gc
if ans1 > ans2:
    print(str(ans1))
else:
    print(str(ans2))