import sys
from collections import Counter
H,W,m = map(int,input().split())
h_ls = [0] * H
w_ls = [0] * W
bombers = [(0,0) for _ in range(m)]
for i in range(m):
    h,w = map(int,input().split())
    h_ls[h-1] += 1
    w_ls[w-1] += 1
    bombers[i] = (h-1,w-1)

h_max = max(h_ls)
h_counter = Counter(h_ls)
# Couter使ってみる
h_max_args = [0]*h_counter[h_max]
next_ind = 0
for i in range(H):
    if h_ls[i] == h_max:
        h_max_args[next_ind] = i
        next_ind += 1

w_max = max(w_ls)
w_counter = Counter(w_ls)
w_max_args = [0]*w_counter[w_max]
next_ind = 0
for i in range(W):
    if w_ls[i] == w_max:
        w_max_args[next_ind] = i
        next_ind += 1

bombers = set(bombers)
for h in h_max_args:
    for w in w_max_args:
        if not (h,w) in bombers:
            print(w_max+h_max)
            sys.exit()

print(w_max+h_max-1) import sys sys 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 h_ls = [0] * H h_ls [0] * H [0] 0 H w_ls = [0] * W w_ls [0] * W [0] 0 W (0,0) for _ in range(m) for _ in range(m) _ range(m) range m for _ in range(m) (0,0) 0 0 bombers = [(0,0) for _ in range(m)] bombers [(0,0) for _ in range(m)] for i in range(m):
    h,w = map(int,input().split())
    h_ls[h-1] += 1
    w_ls[w-1] += 1
    bombers[i] = (h-1,w-1) i range(m) range m h,w = map(int,input().split()) h map(int,input().split()) map int input().split() ().split () input split w h_ls[h-1] += 1 h_ls[h-1] h_ls h-1 h 1 1 w_ls[w-1] += 1 w_ls[w-1] w_ls w-1 w 1 1 bombers[i] = (h-1,w-1) bombers[i] bombers i (h-1,w-1) h-1 h 1 w-1 w 1 h_max = max(h_ls) h_max max(h_ls) max h_ls h_counter = Counter(h_ls) h_counter Counter(h_ls) Counter h_ls h_max_args = [0]*h_counter[h_max] h_max_args [0]*h_counter[h_max] [0] 0 h_counter[h_max] h_counter h_max next_ind = 0 next_ind 0 for i in range(H):
    if h_ls[i] == h_max:
        h_max_args[next_ind] = i
        next_ind += 1 i range(H) range H if h_ls[i] == h_max:
        h_max_args[next_ind] = i
        next_ind += 1 h_ls[i] == h_max h_ls[i] h_ls i h_max h_max_args[next_ind] = i h_max_args[next_ind] h_max_args next_ind i next_ind += 1 next_ind 1 w_max = max(w_ls) w_max max(w_ls) max w_ls w_counter = Counter(w_ls) w_counter Counter(w_ls) Counter w_ls w_max_args = [0]*w_counter[w_max] w_max_args [0]*w_counter[w_max] [0] 0 w_counter[w_max] w_counter w_max next_ind = 0 next_ind 0 for i in range(W):
    if w_ls[i] == w_max:
        w_max_args[next_ind] = i
        next_ind += 1 i range(W) range W if w_ls[i] == w_max:
        w_max_args[next_ind] = i
        next_ind += 1 w_ls[i] == w_max w_ls[i] w_ls i w_max w_max_args[next_ind] = i w_max_args[next_ind] w_max_args next_ind i next_ind += 1 next_ind 1 bombers = set(bombers) bombers set(bombers) set bombers for h in h_max_args:
    for w in w_max_args:
        if not (h,w) in bombers:
            print(w_max+h_max)
            sys.exit() h h_max_args for w in w_max_args:
        if not (h,w) in bombers:
            print(w_max+h_max)
            sys.exit() w w_max_args if not (h,w) in bombers:
            print(w_max+h_max)
            sys.exit() not (h,w) in bombers (h,w) in bombers (h,w) h w bombers print(w_max+h_max) print w_max+h_max w_max h_max sys.exit() sys.exit sys exit print(w_max+h_max-1) print w_max+h_max-1 w_max+h_max w_max h_max 1 h,w = map(int,input().split()) map(int,input().split()) h W,m = map(int,input().split()) map(int,input().split()) W next_ind = 0 0 next_ind w_max_args = [0]*w_counter[w_max] [0]*w_counter[w_max] w_max_args h_counter = Counter(h_ls) Counter(h_ls) h_counter w_max = max(w_ls) max(w_ls) w_max bombers = [(0,0) for _ in range(m)] [(0,0) for _ in range(m)] bombers next_ind += 1 1 next_ind H,W,m = map(int,input().split()) map(int,input().split()) H bombers = set(bombers) set(bombers) bombers h_max = max(h_ls) max(h_ls) h_max w = map(int,input().split()) map(int,input().split()) w h_ls = [0] * H [0] * H h_ls m = map(int,input().split()) map(int,input().split()) m w_counter = Counter(w_ls) Counter(w_ls) w_counter next_ind = 0 0 next_ind next_ind += 1 1 next_ind h_max_args = [0]*h_counter[h_max] [0]*h_counter[h_max] h_max_args w_ls = [0] * W [0] * W w_ls
import sys
from collections import Counter
H,W,m = map(int,input().split())
h_ls = [0] * H
w_ls = [0] * W
bombers = [(0,0) for _ in range(m)]
for i in range(m):
    h,w = map(int,input().split())
    h_ls[h-1] += 1
    w_ls[w-1] += 1
    bombers[i] = (h-1,w-1)

h_max = max(h_ls)
h_counter = Counter(h_ls)
# Couter使ってみる
h_max_args = [0]*h_counter[h_max]
next_ind = 0
for i in range(H):
    if h_ls[i] == h_max:
        h_max_args[next_ind] = i
        next_ind += 1

w_max = max(w_ls)
w_counter = Counter(w_ls)
w_max_args = [0]*w_counter[w_max]
next_ind = 0
for i in range(W):
    if w_ls[i] == w_max:
        w_max_args[next_ind] = i
        next_ind += 1

bombers = set(bombers)
for h in h_max_args:
    for w in w_max_args:
        if not (h,w) in bombers:
            print(w_max+h_max)
            sys.exit()

print(w_max+h_max-1)
