import glob
import os
import numpy as np

bn = os.path.basename(__file__).split('.')[0]
dn = os.path.dirname(__file__).split('/')

# 問題ごとのディレクトリのトップからの相対パス
REL_PATH = dn[len(dn)-2] + '\\' + dn[len(dn)-1] + '\\' + bn

# テスト用ファイル置き場のトップ
TOP_PATH = 'C:\\AtCoder'

class Common:
    problem = []
    index = 0

    def __init__(self, rel_path):
        self.rel_path = rel_path

    def initialize(self, path):
        file = open(path)
        self.problem = file.readlines()
        self.index = 0
        return

    def input_data(self):
        try:
            IS_TEST
            self.index += 1
            return self.problem[self.index - 1]

        except NameError:
            return input()

    def resolve(self):
        pass

    def exec_resolve(self):
        try:
            IS_TEST
            for path in glob.glob(TOP_PATH + '\\' + self.rel_path + '/*.txt'):
                print("Test: " + path)
                self.initialize(path)
                self.resolve()
                print("\n\n")
        except NameError:
            self.resolve()


class Solver(Common):

    def resolve(self):

        H, W, M = map(int, self.input_data().split())
        B = [None for i in range(M)]

        bombs = [[0 for j in range(W+1)] for i in range(H+1)]
        for i in range(M):
            B[i] = list(map(int, self.input_data().split()))
            tmp1 = B[i][0]
            tmp2 = B[i][1]
            bombs[B[i][0]][B[i][1]] = 1

        B_np = np.array(bombs)

        ver_num = np.sum(B_np, axis=0) # 列ごとの合計(行分ある)
        hol_num = np.sum(B_np, axis=1) # 行ごとの合計(列分ある)

        ver_max = np.max(ver_num)
        hol_max = np.max(hol_num)

        max_columns = []
        max_rows = []

        for i in range(W):
            if ver_max == ver_num[i]:
                max_columns.append(i)
        for i in range(H):
            if hol_max == hol_num[i]:
                max_rows.append(i)

        result = ver_max + hol_max - 1
        for c in max_columns:
            for r in max_rows:
                if bombs[c][r] == 0:
                    result = ver_max + hol_max
                else:
                    pass

        print(str(result))

solver = Solver(REL_PATH)
solver.exec_resolve()


### FIXED CODE ###

import glob
import os
import numpy as np

bn = os.path.basename(__file__).split('.')[0]
dn = os.path.dirname(__file__).split('/')

# 問題ごとのディレクトリのトップからの相対パス
REL_PATH = dn[len(dn)-2] + '\\' + dn[len(dn)-1] + '\\' + bn

# テスト用ファイル置き場のトップ
TOP_PATH = 'C:\\AtCoder'

class Common:
    problem = []
    index = 0

    def __init__(self, rel_path):
        self.rel_path = rel_path

    def initialize(self, path):
        file = open(path)
        self.problem = file.readlines()
        self.index = 0
        return

    def input_data(self):
        try:
            IS_TEST
            self.index += 1
            return self.problem[self.index - 1]

        except NameError:
            return input()

    def resolve(self):
        pass

    def exec_resolve(self):
        try:
            IS_TEST
            for path in glob.glob(TOP_PATH + '\\' + self.rel_path + '/*.txt'):
                print("Test: " + path)
                self.initialize(path)
                self.resolve()
                print("\n\n")
        except NameError:
            self.resolve()


class Solver(Common):

    def resolve(self):

        H, W, M = map(int, self.input_data().split())
        B = [None for i in range(M)]

        ver_num =[0 for i in range(W+1)] # 列ごとの合計(行分ある)
        hol_num = [0 for i in range(H+1)] # 行ごとの合計(列分ある)

        for i in range(M):
            B[i] = list(map(int, self.input_data().split()))
            ver_num[B[i][1]] +=1
            hol_num[B[i][0]] +=1

        ver_max = np.max(np.array(ver_num))
        hol_max = np.max(np.array(hol_num))

        max_columns = []
        max_rows = []

        for i in range(1,W+1):
            if ver_max == ver_num[i]:
                max_columns.append(i)
        for i in range(1,H+1):
            if hol_max == hol_num[i]:
                max_rows.append(i)

        b_cross = 0
        for b in B:
            if ver_num[b[1]] == ver_max and hol_num[b[0]] == hol_max:
                b_cross += 1
        if b_cross == len(max_columns) * len(max_rows):
            result = ver_max + hol_max - 1
        else:
            result = ver_max + hol_max
        print(str(result))

solver = Solver(REL_PATH)
solver.exec_resolve()