
Imports System.Console
Module Module1
    Dim ans As Int64
    Dim max As Int64
    Dim n, k, x, t As Int64
    Sub Main()
        Dim s() As String = ReadLine.Split
        Dim h, w As Integer
        Dim m As Integer
        h = s(0)
        w = s(1)
        m = s(2)
        Dim obx(m) As Integer
        Dim oby(m) As Integer
        Dim numw(h) As Int64
        Dim numh(w) As Int64
        For i = 1 To m
            s = ReadLine().Split
            obx(i) = s(1)
            oby(i) = s(0)
            numw(s(0)) += 1
            numh(s(1)) += 1
        Next
        Dim maxindw, maxindh As Integer
        Dim maxws(), maxhs() As Integer
        For i = 1 To w
            If numh(i) > numh(maxindh) Then
                maxindh = i
            End If
        Next
        For i = 1 To w
            If numh(i) = numh(maxindh) Then
                Add(maxhs, i)
            End If
        Next
        For i = 1 To h
            If numw(i) > numw(maxindw) Then
                maxindw = i
            End If
        Next
        For i = 1 To h
            If numw(i) = numw(maxindw) Then
                Add(maxws, i)
            End If
        Next
        Dim found As Boolean = False
        Dim obnum As Integer
        For i = 1 To m
            'For i = 0 To maxhs.Length - 1
            '    'If found = True Then
            '    '    Exit For
            '    'End If
            '    'For ii = 0 To maxws.Length - 1
            '    '    If field(maxhs(i), maxws(ii)) = False Then
            '    '        found = True
            '    '        'Exit For
            '    '    End If
            '    'Next
            '    For ii = 0 To maxws.Length - 1
            '        If obx(iii) = maxhs(i) And oby(iii) = maxws(ii) Then
            '            obnum += 1
            '        End If
            '    Next
            'Next
            If maxws.Contains(oby(i)) And maxhs.Contains(obx(i)) Then
                obnum += 1
            End If
        Next
        If obnum < maxws.Length * maxhs.Length Then
            found = True
        End If
        ans = numw(maxws(0)) + numh(maxhs(0))
        If found = False Then
            ans -= 1
        End If
        WriteLine(ans)
        ReadLine()
    End Sub
    Sub Add(ByRef arr() As Integer, ByVal num As Integer)
        If arr Is Nothing Then
            ReDim arr(0)
            arr(0) = num
        Else
            ReDim Preserve arr(arr.Length)
            arr(arr.Length - 1) = num
        End If
    End Sub
End Module
