import sys

from copy import deepcopy as copy

input = sys.stdin.readline





def main():

    h, w, m = list(map(int, input().split()))

    

    bomb_h = [0]*h

    bomb_w = [0]*w

    bomb_w_place = [set() for _ in range(w)]

    for i in range(m):

        x, y = list(map(int, input().split()))

        bomb_h[x-1] += 1

        bomb_w[y-1] += 1

        bomb_w_place[y-1].add(x-1)

    bomb_h2 = [0]*h

    for i in range(h):

        bomb_h2[i] = [bomb_h[i], i]

    bomb_h2.sort(reverse=True)

    

    ans = 0

    for i in range(w):

        index = 0

        key = bomb_w[i]

        k1, k2 = True, True

        ma = -1

        while index < len(bomb_h2):

            key2 = bomb_h2[index]

            if key2[1] in bomb_w_place[i]:

                if ma == -1:

                    ma = key2[0]-1

                    index += 1

                    continue

                elif ma == key2[0]-1:

                    index += 1

                    continue

                else:

                    break

            else:

                ma = max(ma, key2[0])

                break

            index += 1

        

        ans = max(ans, key+ma)

    print(ans)

        

    

    

if __name__ == "__main__":

    main()



import sys

input = sys.stdin.readline





def main():

    h, w, m = list(map(int, input().split()))

    bomb = [tuple(map(int, input().split())) for _ in range(m)]

    

    bom_h = [0]*h

    bom_w = [0]*w

    

    for i in range(m):

        x, y = bomb[i]

        bom_h[x-1] += 1

        bom_w[y-1] += 1

    

    max_h = max(bom_h)

    max_w = max(bom_w)

    

    ans = bom_h.count(max_h)*bom_w.count(max_w)

    for i in range(m):

        x, y = bomb[i]

        if bom_h[x-1] == max_h and bom_w[y-1] == max_w:

            ans -= 1

    

    print((max_h+max_w+bool(ans)-1))

    

    

    

if __name__ == "__main__":

    main()



import sys
from copy import deepcopy as copy

input = sys.stdin.readline


def main():
    h, w, m = list(map(int, input().split()))
    bomb_h = [0] * h
    bomb_w = [0] * w
    bomb_w_place = [set() for _ in range(w)]
    for i in range(m):
        x, y = list(map(int, input().split()))
        bomb_h[x - 1] += 1
        bomb_w[y - 1] += 1
        bomb_w_place[y - 1].add(x - 1)
    bomb_h2 = [0] * h
    for i in range(h):
        bomb_h2[i] = [bomb_h[i], i]
    bomb_h2.sort(reverse=True)
    ans = 0
    for i in range(w):
        index = 0
        key = bomb_w[i]
        k1, k2 = True, True
        ma = -1
        while index < len(bomb_h2):
            key2 = bomb_h2[index]
            if key2[1] in bomb_w_place[i]:
                if ma == -1:
                    ma = key2[0] - 1
                    index += 1
                    continue
                elif ma == key2[0] - 1:
                    index += 1
                    continue
                else:
                    break
            else:
                ma = max(ma, key2[0])
                break
            index += 1
        ans = max(ans, key + ma)
    print(ans)


if __name__ == "__main__":
    main()

import sys

input = sys.stdin.readline


def main():
    h, w, m = list(map(int, input().split()))
    bomb = [tuple(map(int, input().split())) for _ in range(m)]
    bom_h = [0] * h
    bom_w = [0] * w
    for i in range(m):
        x, y = bomb[i]
        bom_h[x - 1] += 1
        bom_w[y - 1] += 1
    max_h = max(bom_h)
    max_w = max(bom_w)
    ans = bom_h.count(max_h) * bom_w.count(max_w)
    for i in range(m):
        x, y = bomb[i]
        if bom_h[x - 1] == max_h and bom_w[y - 1] == max_w:
            ans -= 1
    print((max_h + max_w + bool(ans) - 1))


if __name__ == "__main__":
    main()

-from copy import deepcopy as copy -    bomb_h = [0] * h -    bomb_w = [0] * w -    bomb_w_place = [set() for _ in range(w)] +    bomb = [tuple(map(int, input().split())) for _ in range(m)] +    bom_h = [0] * h +    bom_w = [0] * w -        x, y = list(map(int, input().split())) -        bomb_h[x - 1] += 1 -        bomb_w[y - 1] += 1 -        bomb_w_place[y - 1].add(x - 1) -    bomb_h2 = [0] * h -    for i in range(h): -        bomb_h2[i] = [bomb_h[i], i] -    bomb_h2.sort(reverse=True) -    ans = 0 -    for i in range(w): -        index = 0 -        key = bomb_w[i] -        k1, k2 = True, True -        ma = -1 -        while index < len(bomb_h2): -            key2 = bomb_h2[index] -            if key2[1] in bomb_w_place[i]: -                if ma == -1: -                    ma = key2[0] - 1 -                    index += 1 -                    continue -                elif ma == key2[0] - 1: -                    index += 1 -                    continue -                else: -                    break -            else: -                ma = max(ma, key2[0]) -                break -            index += 1 -        ans = max(ans, key + ma) -    print(ans) +        x, y = bomb[i] +        bom_h[x - 1] += 1 +        bom_w[y - 1] += 1 +    max_h = max(bom_h) +    max_w = max(bom_w) +    ans = bom_h.count(max_h) * bom_w.count(max_w) +    for i in range(m): +        x, y = bomb[i] +        if bom_h[x - 1] == max_h and bom_w[y - 1] == max_w: +            ans -= 1 +    print((max_h + max_w + bool(ans) - 1))