from collections import Counter

h, w, m = map(int, input().split())
beds = [tuple(map(lambda x: int(x) - 1, input().split()))  for _ in range(m)]

bom_v = Counter(b[0] for b in beds)
bom_h = Counter(b[1] for b in beds)

v_max = max(bom_v.values())
h_max = max(bom_h.values())

cand = list(bom_v.values()).count(v_max) * list(bom_h.values()).count(h_max)
bombs = len([... for i, j in beds if bom_v[i] ==  v_max and bom_h[j] ==  h_max])

if cand - bombs > 0:
    print(v_max + h_max)
else:
    print(v_max + h_max - 1) from collections import Counter h, w, m = map(int, input().split()) h map(int, input().split()) map int input().split() ().split () input split w m tuple(map(lambda x: int(x) - 1, input().split()))  for _ in range(m) for _ in range(m) _ range(m) range m for _ in range(m) tuple(map(lambda x: int(x) - 1, input().split())) tuple map(lambda x: int(x) - 1, input().split()) map lambda x: int(x) - 1 int(x) - 1 int(x) int x 1 x input().split() ().split () input split beds = [tuple(map(lambda x: int(x) - 1, input().split()))  for _ in range(m)] beds [tuple(map(lambda x: int(x) - 1, input().split()))  for _ in range(m)] bom_v = Counter(b[0] for b in beds) bom_v Counter(b[0] for b in beds) Counter b[0] b 0 bom_h = Counter(b[1] for b in beds) bom_h Counter(b[1] for b in beds) Counter b[1] b 1 v_max = max(bom_v.values()) v_max max(bom_v.values()) max bom_v.values() bom_v.values bom_v values h_max = max(bom_h.values()) h_max max(bom_h.values()) max bom_h.values() bom_h.values bom_h values cand = list(bom_v.values()).count(v_max) * list(bom_h.values()).count(h_max) cand list(bom_v.values()).count(v_max) * list(bom_h.values()).count(h_max) list(bom_v.values()).count(v_max) (bom_v.values()).count (bom_v.values()) list bom_v.values() bom_v.values bom_v values count v_max list(bom_h.values()).count(h_max) (bom_h.values()).count (bom_h.values()) list bom_h.values() bom_h.values bom_h values count h_max ... for i, j in beds if bom_v[i] ==  v_max and bom_h[j] ==  h_max for i, j in beds if bom_v[i] ==  v_max and bom_h[j] ==  h_max i j beds bom_v[i] ==  v_max and bom_h[j] ==  h_max bom_v[i] ==  v_max bom_v[i] bom_v i v_max bom_h[j] ==  h_max bom_h[j] bom_h j h_max if bom_v[i] ==  v_max and bom_h[j] ==  h_max ... bombs = len([... for i, j in beds if bom_v[i] ==  v_max and bom_h[j] ==  h_max]) bombs len([... for i, j in beds if bom_v[i] ==  v_max and bom_h[j] ==  h_max]) len [... for i, j in beds if bom_v[i] ==  v_max and bom_h[j] ==  h_max] if cand - bombs > 0:
    print(v_max + h_max)
else:
    print(v_max + h_max - 1) cand - bombs > 0 cand - bombs cand bombs 0 print(v_max + h_max) print v_max + h_max v_max h_max print(v_max + h_max - 1) print v_max + h_max - 1 v_max + h_max v_max h_max 1 bom_v = Counter(b[0] for b in beds) Counter(b[0] for b in beds) bom_v beds = [tuple(map(lambda x: int(x) - 1, input().split()))  for _ in range(m)] [tuple(map(lambda x: int(x) - 1, input().split()))  for _ in range(m)] beds v_max = max(bom_v.values()) max(bom_v.values()) v_max h, w, m = map(int, input().split()) map(int, input().split()) h cand = list(bom_v.values()).count(v_max) * list(bom_h.values()).count(h_max) list(bom_v.values()).count(v_max) * list(bom_h.values()).count(h_max) cand bombs = len([... for i, j in beds if bom_v[i] ==  v_max and bom_h[j] ==  h_max]) len([... for i, j in beds if bom_v[i] ==  v_max and bom_h[j] ==  h_max]) bombs m = map(int, input().split()) map(int, input().split()) m h_max = max(bom_h.values()) max(bom_h.values()) h_max w, m = map(int, input().split()) map(int, input().split()) w bom_h = Counter(b[1] for b in beds) Counter(b[1] for b in beds) bom_h
from collections import Counter

h, w, m = map(int, input().split())
beds = [tuple(map(lambda x: int(x) - 1, input().split()))  for _ in range(m)]

bom_v = Counter(b[0] for b in beds)
bom_h = Counter(b[1] for b in beds)

v_max = max(bom_v.values())
h_max = max(bom_h.values())

cand = list(bom_v.values()).count(v_max) * list(bom_h.values()).count(h_max)
bombs = len([... for i, j in beds if bom_v[i] ==  v_max and bom_h[j] ==  h_max])

if cand - bombs > 0:
    print(v_max + h_max)
else:
    print(v_max + h_max - 1)