package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

func main() {
	sc := NewScanner()

	h := sc.ReadInt()
	w := sc.ReadInt()
	m := sc.ReadInt()

	targetPoints := make(map[Point]bool)
	targetCountPerH := make([]int, h+1)
	targetCountPerW := make([]int, w+1)
	for i := 0; i < m; i++ {
		hi := sc.ReadInt()
		wi := sc.ReadInt()
		pi := Point{hi, wi}
		targetCountPerH[hi]++
		targetCountPerW[wi]++
		targetPoints[pi] = true
	}

	var bombHs []int
	maxTargetCountPerH := 0
	for i := 1; i <= h; i++ {
		if targetCountPerH[i] > maxTargetCountPerH {
			maxTargetCountPerH = targetCountPerH[i]
			bombHs = []int{i}
		} else if targetCountPerH[i] == maxTargetCountPerH {
			bombHs = append(bombHs, i)
		}
	}

	var bombWs []int
	maxTargetCountPerW := 0
	for i := 1; i <= w; i++ {
		if targetCountPerW[i] > maxTargetCountPerW {
			maxTargetCountPerW = targetCountPerW[i]
			bombWs = []int{i}
		} else if targetCountPerW[i] == maxTargetCountPerW {
			bombWs = append(bombWs, i)
		}
	}

	targetCross := true
	for _, bombH := range bombHs {
		broken := false
		for _, bombW := range bombWs {
			p := Point{bombH, bombW}
			if !targetPoints[p] {
				targetCross = false
				broken = true
				break
			}
		}
		if broken {
			break
		}
	}

	maxTargetCount := maxTargetCountPerH + maxTargetCountPerW
	if targetCross {
		maxTargetCount--
	}

	fmt.Println(maxTargetCount)
}

type Point struct {
	H int
	W int
}

// from [my library](https://github.com/ikngtty/go-contestlib)
// -   math/simple

func Abs(x int) int {
	if x >= 0 {
		return x
	}
	return -x
}

func Min(values ...int) int {
	if len(values) == 0 {
		panic("no values")
	}

	min := values[0]
	for _, v := range values {
		if v < min {
			min = v
		}
	}
	return min
}

func Max(values ...int) int {
	if len(values) == 0 {
		panic("no values")
	}

	max := values[0]
	for _, v := range values {
		if v > max {
			max = v
		}
	}
	return max
}

func Pow(base, exponent int) int {
	if exponent < 0 {
		panic(fmt.Sprintf("exponent (%d) should not be a minus", exponent))
	}

	answer := 1
	for i := 0; i < exponent; i++ {
		answer *= base
	}
	return answer
}

func Ceil(divident, dividor int) int {
	if dividor == 0 {
		panic("dividor should not be 0")
	}

	quo := divident / dividor
	rem := divident % dividor

	if rem != 0 {
		if (divident > 0 && dividor > 0) ||
			(divident < 0 && dividor < 0) {
			return quo + 1
		}
	}
	return quo
}

// -   sortutil

func ReverseInts(a []int) {
	sort.Sort(sort.Reverse(sort.IntSlice(a)))
}

func ReverseStrings(a []string) {
	sort.Sort(sort.Reverse(sort.StringSlice(a)))
}

// -   io

type Scanner struct {
	bufScanner *bufio.Scanner
}

func NewScanner() *Scanner {
	bufSc := bufio.NewScanner(os.Stdin)
	bufSc.Split(bufio.ScanWords)
	bufSc.Buffer(nil, 100000000)
	return &Scanner{bufSc}
}

func (sc *Scanner) ReadString() string {
	bufSc := sc.bufScanner
	bufSc.Scan()
	return bufSc.Text()
}

func (sc *Scanner) ReadInt() int {
	bufSc := sc.bufScanner
	bufSc.Scan()
	text := bufSc.Text()

	num, err := strconv.Atoi(text)
	if err != nil {
		panic(err)
	}
	return num
}

func (sc *Scanner) ReadFloat() float64 {
	bufSc := sc.bufScanner
	bufSc.Scan()
	text := bufSc.Text()

	num, err := strconv.ParseFloat(text, 64)
	if err != nil {
		panic(err)
	}
	return num
}


Measured memory_bytes: 47024