def main():

    H, W, M = map(int, input().split())
    h_dic = [0] * H
    w_dic = [0] * W
    boms = set()
    for _ in range(M):
        h, w = map(int, input().split())
        h, w = h-1, w-1
        h_dic[h] += 1
        w_dic[w] += 1
        boms.add((h, w))

    hmax = max(h_dic)
    wmax = max(w_dic)

    h_maxs = [idx for idx, v in enumerate(h_dic) if v==hmax]
    w_maxs = [idx for idx, v in enumerate(w_dic) if v==wmax]

    # 爆弾数はたかだか3*10~5なので、総当りで解ける
    for h in h_maxs:
        for w in w_maxs:
            if (h, w) not in boms:
                print(hmax + wmax)
                return
    print(hmax + wmax - 1)
    return

if __name__ == "__main__":
    main() def main():

    H, W, M = map(int, input().split())
    h_dic = [0] * H
    w_dic = [0] * W
    boms = set()
    for _ in range(M):
        h, w = map(int, input().split())
        h, w = h-1, w-1
        h_dic[h] += 1
        w_dic[w] += 1
        boms.add((h, w))

    hmax = max(h_dic)
    wmax = max(w_dic)

    h_maxs = [idx for idx, v in enumerate(h_dic) if v==hmax]
    w_maxs = [idx for idx, v in enumerate(w_dic) if v==wmax]

    # 爆弾数はたかだか3*10~5なので、総当りで解ける
    for h in h_maxs:
        for w in w_maxs:
            if (h, w) not in boms:
                print(hmax + wmax)
                return
    print(hmax + wmax - 1)
    return main H, W, M = map(int, input().split()) H map(int, input().split()) map int input().split() ().split () input split W M h_dic = [0] * H h_dic [0] * H [0] 0 H w_dic = [0] * W w_dic [0] * W [0] 0 W boms = set() boms set() set for _ in range(M):
        h, w = map(int, input().split())
        h, w = h-1, w-1
        h_dic[h] += 1
        w_dic[w] += 1
        boms.add((h, w))

     _ range(M) range M h, w = map(int, input().split()) h map(int, input().split()) map int input().split() ().split () input split w h, w = h-1, w-1 h h-1 h 1 w w-1 w 1 h_dic[h] += 1 h_dic[h] h_dic h 1 w_dic[w] += 1 w_dic[w] w_dic w 1 boms.add((h, w)) boms.add boms add (h, w) h w hmax = max(h_dic) hmax max(h_dic) max h_dic wmax = max(w_dic) wmax max(w_dic) max w_dic idx for idx, v in enumerate(h_dic) if v==hmax for idx, v in enumerate(h_dic) if v==hmax idx v enumerate(h_dic) enumerate h_dic v==hmax v hmax if v==hmax idx h_maxs = [idx for idx, v in enumerate(h_dic) if v==hmax] h_maxs [idx for idx, v in enumerate(h_dic) if v==hmax] idx for idx, v in enumerate(w_dic) if v==wmax for idx, v in enumerate(w_dic) if v==wmax idx v enumerate(w_dic) enumerate w_dic v==wmax v wmax if v==wmax idx w_maxs = [idx for idx, v in enumerate(w_dic) if v==wmax] w_maxs [idx for idx, v in enumerate(w_dic) if v==wmax] for h in h_maxs:
        for w in w_maxs:
            if (h, w) not in boms:
                print(hmax + wmax)
                return
     h h_maxs for w in w_maxs:
            if (h, w) not in boms:
                print(hmax + wmax)
                return
     w w_maxs if (h, w) not in boms:
                print(hmax + wmax)
                return
     (h, w) not in boms (h, w) h w boms print(hmax + wmax) print hmax + wmax hmax wmax return print(hmax + wmax - 1) print hmax + wmax - 1 hmax + wmax hmax wmax 1 return if __name__ == "__main__":
    main() __name__ == "__main__" __name__ "__main__" main() main def main():

    H, W, M = map(int, input().split())
    h_dic = [0] * H
    w_dic = [0] * W
    boms = set()
    for _ in range(M):
        h, w = map(int, input().split())
        h, w = h-1, w-1
        h_dic[h] += 1
        w_dic[w] += 1
        boms.add((h, w))

    hmax = max(h_dic)
    wmax = max(w_dic)

    h_maxs = [idx for idx, v in enumerate(h_dic) if v==hmax]
    w_maxs = [idx for idx, v in enumerate(w_dic) if v==wmax]

    # 爆弾数はたかだか3*10~5なので、総当りで解ける
    for h in h_maxs:
        for w in w_maxs:
            if (h, w) not in boms:
                print(hmax + wmax)
                return
    print(hmax + wmax - 1)
    return def main():

    H, W, M = map(int, input().split())
    h_dic = [0] * H
    w_dic = [0] * W
    boms = set()
    for _ in range(M):
        h, w = map(int, input().split())
        h, w = h-1, w-1
        h_dic[h] += 1
        w_dic[w] += 1
        boms.add((h, w))

    hmax = max(h_dic)
    wmax = max(w_dic)

    h_maxs = [idx for idx, v in enumerate(h_dic) if v==hmax]
    w_maxs = [idx for idx, v in enumerate(w_dic) if v==wmax]

    # 爆弾数はたかだか3*10~5なので、総当りで解ける
    for h in h_maxs:
        for w in w_maxs:
            if (h, w) not in boms:
                print(hmax + wmax)
                return
    print(hmax + wmax - 1)
    return main
def main():

    H, W, M = map(int, input().split())
    h_dic = [0] * H
    w_dic = [0] * W
    boms = set()
    for _ in range(M):
        h, w = map(int, input().split())
        h, w = h-1, w-1
        h_dic[h] += 1
        w_dic[w] += 1
        boms.add((h, w))

    hmax = max(h_dic)
    wmax = max(w_dic)

    h_maxs = [idx for idx, v in enumerate(h_dic) if v==hmax]
    w_maxs = [idx for idx, v in enumerate(w_dic) if v==wmax]

    # 爆弾数はたかだか3*10~5なので、総当りで解ける
    for h in h_maxs:
        for w in w_maxs:
            if (h, w) not in boms:
                print(hmax + wmax)
                return
    print(hmax + wmax - 1)
    return

if __name__ == "__main__":
    main()
