import sys

read = sys.stdin.read

readlines = sys.stdin.readlines

from collections import defaultdict

def main():

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

    rows = defaultdict(int)

    cols = defaultdict(int)

    d1 = lambda :defaultdict(int)

    d2 = defaultdict(d1)

    m = list(map(int, read().split()))

    ab = list(zip(m, m))

    for a, b in ab:

        rows[a-1] += 1

        cols[b-1] += 1

        d2[a-1][b-1] = 1

    rm = max(rows.values())

    cm = max(cols.values())

    rs = [i for i, v in list(rows.items()) if v == rm]

    cs = [i for i, v in list(cols.items()) if v == cm]

    r = rm + cm

    #p = set()

    for rse in rs:

        for cse in cs:

            if d2[rse][cse] == 0:

                print(r)

                sys.exit()

    print((r-1))





if __name__ == '__main__':

    main()
import sys

read = sys.stdin.read

#readlines = sys.stdin.readlines

def main():

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

    b_row = [0] * h

    b_col = [0] * w

    b_coor = set()

    m = list(map(int, read().split()))

    for a, b in zip(m, m):

        a -= 1

        b -= 1

        b_row[a] += 1

        b_col[b] += 1

        b_coor.add((a, b))



    row_max = max(b_row)

    col_max = max(b_col)

    rows = [i for i, v in enumerate(b_row) if v == row_max]

    cols = [i for i, v in enumerate(b_col) if v == col_max]



    for r in rows:

        for c in cols:

            if (r, c) not in b_coor:

                print((row_max + col_max))

                sys.exit()

    print((row_max + col_max - 1))



if __name__ == '__main__':

    main()

import sys

read = sys.stdin.read
readlines = sys.stdin.readlines
from collections import defaultdict


def main():
    h, w, m = list(map(int, input().split()))
    rows = defaultdict(int)
    cols = defaultdict(int)
    d1 = lambda: defaultdict(int)
    d2 = defaultdict(d1)
    m = list(map(int, read().split()))
    ab = list(zip(m, m))
    for a, b in ab:
        rows[a - 1] += 1
        cols[b - 1] += 1
        d2[a - 1][b - 1] = 1
    rm = max(rows.values())
    cm = max(cols.values())
    rs = [i for i, v in list(rows.items()) if v == rm]
    cs = [i for i, v in list(cols.items()) if v == cm]
    r = rm + cm
    # p = set()
    for rse in rs:
        for cse in cs:
            if d2[rse][cse] == 0:
                print(r)
                sys.exit()
    print((r - 1))


if __name__ == "__main__":
    main()

import sys

read = sys.stdin.read
# readlines = sys.stdin.readlines
def main():
    h, w, m = list(map(int, input().split()))
    b_row = [0] * h
    b_col = [0] * w
    b_coor = set()
    m = list(map(int, read().split()))
    for a, b in zip(m, m):
        a -= 1
        b -= 1
        b_row[a] += 1
        b_col[b] += 1
        b_coor.add((a, b))
    row_max = max(b_row)
    col_max = max(b_col)
    rows = [i for i, v in enumerate(b_row) if v == row_max]
    cols = [i for i, v in enumerate(b_col) if v == col_max]
    for r in rows:
        for c in cols:
            if (r, c) not in b_coor:
                print((row_max + col_max))
                sys.exit()
    print((row_max + col_max - 1))


if __name__ == "__main__":
    main()

-readlines = sys.stdin.readlines -from collections import defaultdict - - +# readlines = sys.stdin.readlines -    rows = defaultdict(int) -    cols = defaultdict(int) -    d1 = lambda: defaultdict(int) -    d2 = defaultdict(d1) +    b_row = [0] * h +    b_col = [0] * w +    b_coor = set() -    ab = list(zip(m, m)) -    for a, b in ab: -        rows[a - 1] += 1 -        cols[b - 1] += 1 -        d2[a - 1][b - 1] = 1 -    rm = max(rows.values()) -    cm = max(cols.values()) -    rs = [i for i, v in list(rows.items()) if v == rm] -    cs = [i for i, v in list(cols.items()) if v == cm] -    r = rm + cm -    # p = set() -    for rse in rs: -        for cse in cs: -            if d2[rse][cse] == 0: -                print(r) +    for a, b in zip(m, m): +        a -= 1 +        b -= 1 +        b_row[a] += 1 +        b_col[b] += 1 +        b_coor.add((a, b)) +    row_max = max(b_row) +    col_max = max(b_col) +    rows = [i for i, v in enumerate(b_row) if v == row_max] +    cols = [i for i, v in enumerate(b_col) if v == col_max] +    for r in rows: +        for c in cols: +            if (r, c) not in b_coor: +                print((row_max + col_max)) -    print((r - 1)) +    print((row_max + col_max - 1))