# Date [ 2020-08-23 14:02:31 ]
# Problem [ e.py ]
# Author Koki_tkg
# After Contest

import sys;          from decimal import Decimal
import math;         from numba import njit, i8, u1, b1
import bisect;       from itertools import combinations, product
import numpy as np;  from collections import Counter, deque, defaultdict

# sys.setrecursionlimit(10 ** 6)
MOD = 10 ** 9 + 7
INF = 10 ** 9
PI = 3.14159265358979323846

def read_str():      return sys.stdin.readline().strip()
def read_int():      return int(sys.stdin.readline().strip())
def read_ints(x=0):  return map(lambda num: int(num) - x, sys.stdin.readline().strip().split())
def read_str_list(): return list(sys.stdin.readline().strip().split())
def read_int_list(): return list(map(int, sys.stdin.readline().strip().split()))
def lcm(a: int, b: int) -> int: return (a * b) // math.gcd(a, b)

def solve(h,w,bomb):
    row = np.zeros(h, dtype=np.int64)
    column = np.zeros(w, dtype=np.int64)
    
    for y, x in bomb:
        row[y] += 1
        column[x] += 1
        
    max_row = np.max(row)
    max_col = np.max(column)
    val = max_row + max_col

    max_row_lis = np.ravel(np.where(row == row.max()))
    max_col_lis = np.ravel(np.where(column == column.max()))

    for r in max_row_lis:
        for c in max_col_lis:
            if (r, c) not in bomb:
                return val
    
    return val - 1
    

def Main():
    h, w, m = read_ints()
    bomb = set([tuple(read_ints(x=1)) for _ in range(m)])
    
    print(solve(h, w, bomb))


if __name__ == '__main__':
    Main() import sys sys from decimal import Decimal import math math from numba import njit, i8, u1, b1 import bisect bisect from itertools import combinations, product import numpy as np numpy from collections import Counter, deque, defaultdict MOD = 10 ** 9 + 7 MOD 10 ** 9 + 7 10 ** 9 10 9 7 INF = 10 ** 9 INF 10 ** 9 10 9 PI = 3.14159265358979323846 PI 3.14159265358979323846 def read_str():      return sys.stdin.readline().strip() read_str def read_int():      return int(sys.stdin.readline().strip()) read_int def read_ints(x=0):  return map(lambda num: int(num) - x, sys.stdin.readline().strip().split()) read_ints x=0 x 0 def read_str_list(): return list(sys.stdin.readline().strip().split()) read_str_list def read_int_list(): return list(map(int, sys.stdin.readline().strip().split())) read_int_list def lcm(a: int, b: int) -> int: return (a * b) // math.gcd(a, b) lcm a: int a b: int b def solve(h,w,bomb):
    row = np.zeros(h, dtype=np.int64)
    column = np.zeros(w, dtype=np.int64)
    
    for y, x in bomb:
        row[y] += 1
        column[x] += 1
        
    max_row = np.max(row)
    max_col = np.max(column)
    val = max_row + max_col

    max_row_lis = np.ravel(np.where(row == row.max()))
    max_col_lis = np.ravel(np.where(column == column.max()))

    for r in max_row_lis:
        for c in max_col_lis:
            if (r, c) not in bomb:
                return val
    
    return val - 1
     solve row = np.zeros(h, dtype=np.int64) row np.zeros(h, dtype=np.int64) np.zeros np zeros h dtype=np.int64 dtype np.int64 np int64 column = np.zeros(w, dtype=np.int64) column np.zeros(w, dtype=np.int64) np.zeros np zeros w dtype=np.int64 dtype np.int64 np int64 for y, x in bomb:
        row[y] += 1
        column[x] += 1
        
     y x bomb row[y] += 1 row[y] row y 1 column[x] += 1 column[x] column x 1 max_row = np.max(row) max_row np.max(row) np.max np max row max_col = np.max(column) max_col np.max(column) np.max np max column val = max_row + max_col val max_row + max_col max_row max_col max_row_lis = np.ravel(np.where(row == row.max())) max_row_lis np.ravel(np.where(row == row.max())) np.ravel np ravel np.where(row == row.max()) np.where np where row == row.max() row row.max() row.max row max max_col_lis = np.ravel(np.where(column == column.max())) max_col_lis np.ravel(np.where(column == column.max())) np.ravel np ravel np.where(column == column.max()) np.where np where column == column.max() column column.max() column.max column max for r in max_row_lis:
        for c in max_col_lis:
            if (r, c) not in bomb:
                return val
    
     r max_row_lis for c in max_col_lis:
            if (r, c) not in bomb:
                return val
    
     c max_col_lis if (r, c) not in bomb:
                return val
    
     (r, c) not in bomb (r, c) r c bomb return val val return val - 1 val - 1 val 1 h h w w bomb bomb def Main():
    h, w, m = read_ints()
    bomb = set([tuple(read_ints(x=1)) for _ in range(m)])
    
    print(solve(h, w, bomb)) Main h, w, m = read_ints() h read_ints() read_ints w m tuple(read_ints(x=1)) for _ in range(m) for _ in range(m) _ range(m) range m for _ in range(m) tuple(read_ints(x=1)) tuple read_ints(x=1) read_ints x=1 x 1 bomb = set([tuple(read_ints(x=1)) for _ in range(m)]) bomb set([tuple(read_ints(x=1)) for _ in range(m)]) set [tuple(read_ints(x=1)) for _ in range(m)] print(solve(h, w, bomb)) print solve(h, w, bomb) solve h w bomb if __name__ == '__main__':
    Main() __name__ == '__main__' __name__ '__main__' Main() Main def read_int():      return int(sys.stdin.readline().strip()) def read_int():      return int(sys.stdin.readline().strip()) read_int def solve(h,w,bomb):
    row = np.zeros(h, dtype=np.int64)
    column = np.zeros(w, dtype=np.int64)
    
    for y, x in bomb:
        row[y] += 1
        column[x] += 1
        
    max_row = np.max(row)
    max_col = np.max(column)
    val = max_row + max_col

    max_row_lis = np.ravel(np.where(row == row.max()))
    max_col_lis = np.ravel(np.where(column == column.max()))

    for r in max_row_lis:
        for c in max_col_lis:
            if (r, c) not in bomb:
                return val
    
    return val - 1
     def solve(h,w,bomb):
    row = np.zeros(h, dtype=np.int64)
    column = np.zeros(w, dtype=np.int64)
    
    for y, x in bomb:
        row[y] += 1
        column[x] += 1
        
    max_row = np.max(row)
    max_col = np.max(column)
    val = max_row + max_col

    max_row_lis = np.ravel(np.where(row == row.max()))
    max_col_lis = np.ravel(np.where(column == column.max()))

    for r in max_row_lis:
        for c in max_col_lis:
            if (r, c) not in bomb:
                return val
    
    return val - 1
     solve def read_str_list(): return list(sys.stdin.readline().strip().split()) def read_str_list(): return list(sys.stdin.readline().strip().split()) read_str_list def Main():
    h, w, m = read_ints()
    bomb = set([tuple(read_ints(x=1)) for _ in range(m)])
    
    print(solve(h, w, bomb)) def Main():
    h, w, m = read_ints()
    bomb = set([tuple(read_ints(x=1)) for _ in range(m)])
    
    print(solve(h, w, bomb)) Main MOD = 10 ** 9 + 7 10 ** 9 + 7 MOD def lcm(a: int, b: int) -> int: return (a * b) // math.gcd(a, b) def lcm(a: int, b: int) -> int: return (a * b) // math.gcd(a, b) lcm def read_ints(x=0):  return map(lambda num: int(num) - x, sys.stdin.readline().strip().split()) def read_ints(x=0):  return map(lambda num: int(num) - x, sys.stdin.readline().strip().split()) read_ints PI = 3.14159265358979323846 3.14159265358979323846 PI def read_int_list(): return list(map(int, sys.stdin.readline().strip().split())) def read_int_list(): return list(map(int, sys.stdin.readline().strip().split())) read_int_list INF = 10 ** 9 10 ** 9 INF def read_str():      return sys.stdin.readline().strip() def read_str():      return sys.stdin.readline().strip() read_str
# Date [ 2020-08-23 14:02:31 ]
# Problem [ e.py ]
# Author Koki_tkg
# After Contest

import sys;          from decimal import Decimal
import math;         from numba import njit, i8, u1, b1
import bisect;       from itertools import combinations, product
import numpy as np;  from collections import Counter, deque, defaultdict

# sys.setrecursionlimit(10 ** 6)
MOD = 10 ** 9 + 7
INF = 10 ** 9
PI = 3.14159265358979323846

def read_str():      return sys.stdin.readline().strip()
def read_int():      return int(sys.stdin.readline().strip())
def read_ints(x=0):  return map(lambda num: int(num) - x, sys.stdin.readline().strip().split())
def read_str_list(): return list(sys.stdin.readline().strip().split())
def read_int_list(): return list(map(int, sys.stdin.readline().strip().split()))
def lcm(a: int, b: int) -> int: return (a * b) // math.gcd(a, b)

def solve(h,w,bomb):
    row = np.zeros(h, dtype=np.int64)
    column = np.zeros(w, dtype=np.int64)
    
    for y, x in bomb:
        row[y] += 1
        column[x] += 1
        
    max_row = np.max(row)
    max_col = np.max(column)
    val = max_row + max_col

    max_row_lis = np.ravel(np.where(row == row.max()))
    max_col_lis = np.ravel(np.where(column == column.max()))

    for r in max_row_lis:
        for c in max_col_lis:
            if (r, c) not in bomb:
                return val
    
    return val - 1
    

def Main():
    h, w, m = read_ints()
    bomb = set([tuple(read_ints(x=1)) for _ in range(m)])
    
    print(solve(h, w, bomb))


if __name__ == '__main__':
    Main()