package main

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

type bome struct {
	index int

}
func main() {
	scan_init()
	h := scanInt()
	w := scanInt()
	m := scanInt()
	bomed_h := make([]int,m)
	bomed_w := make([]int,m)
	// bomeMap := make([][]int,h)
	for i:= 0; i<h; i++ {
	// 	bomeMap[i] = make([]int,w)
	}
	hCount := make([]int,h)
	wCount := make([]int,w)
	Hbomes := map[int]bool{}
	Wbomes := map[int]bool{}
	memo := map[string]bool{}
	for i:= 0; i<m; i++ {
		bomed_h[i] = scanInt()-1
		bomed_w[i] = scanInt()-1
		Hbomes[bomed_h[i]] = true
		Wbomes[bomed_w[i]] = true
		trans := strconv.Itoa(bomed_h[i]) + strconv.Itoa(bomed_w[i])
		memo[trans] = true
	// 	bomeMap[bomed_h[i]][bomed_w[i]] = 1
		hCount[bomed_h[i]]++
		wCount[bomed_w[i]]++
	}
	maxH := 0
	maxHindexs := []int{}
	for i:= 0; i<h; i++ {
		if maxH < hCount[i] {
			maxH = hCount[i]
			// maxHIndex = i
		}
	}
	for i:= 0; i<h; i++ {
		if maxH == hCount[i] {
			maxHindexs = append(maxHindexs, i)
		}
	}
	// maxWIndex := 0
	maxW := 0
	maxWindexs := []int{}
	for i:= 0; i<w; i++ {
		if maxW < wCount[i] {
			maxW = wCount[i]
			// maxWIndex = i
		}
	}
	for i:= 0; i<w; i++ {
		if maxW == wCount[i] {
			maxWindexs = append(maxWindexs, i)
		}
	}
	// Hsuka := []int{}
	target := 0
	target = maxH + maxW -1
	//maxHcount := len(maxHindexs)
	//maxWcount := len(maxWindexs)
	nasi := false
	for i:= 0; i<len(maxHindexs); i++ {
		for j:= 0; j<len(maxWindexs); j++ {
			getH := maxHindexs[i]
			getW := maxWindexs[j]
			trans := strconv.Itoa(getH) + strconv.Itoa(getW)
			// fmt.Println(trans, memo, i, j)
			if _,ok := memo[trans]; !ok {
				target ++
				nasi = true
				break
			}
		}
		if nasi {
			break
		}
	}

	//for i:= 0; i<w; i++ {
	//	get := maxHindexs[i]
	//	if _,ok := Hbomes[get]; ok {
	//		target--
	//		nasi = true
	//		break
	//	}
	//}
	//if !nasi {
	//	for i:= 0; i<len(maxWindexs); i++ {
	//		get := maxWindexs[i]
	//		if _,ok := Wbomes[get]; ok {
	//			target--
	//			nasi = true
	//			break
	//		}
	//	}
	//}
	//takeH:= hCount[maxHIndex]
	//takeW:= wCount[maxWIndex]
	// nasi := false3 3 4
	//3 3
	//3 1
	//1 1
	//1 2
	// nasi := false
	fmt.Println(target)
	//for i:=0; i<m; i++ {
	//	targeth := bomed_h[i]
	//	targetw := bomed_w[i]
	//
	//}
	// fmt.Println(target)
}

var sc = bufio.NewScanner(os.Stdin)

func scan_init() {
	sc.Split(bufio.ScanWords)
}
func scanInt() int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return i
}
func scan() string {
	sc.Scan()
	return sc.Text()
}

var rdr = bufio.NewReaderSize(os.Stdin, 200000)

func readLine() string {
	buf := make([]byte, 0, 200000)
	for {
		l, p, e := rdr.ReadLine()
		if e != nil {
			panic(e)
		}
		buf = append(buf, l...)
		if !p {
			break
		}
	}
	return string(buf)
}
func readLineToNumber() int {
	S := readLine()
	number, _ := strconv.Atoi(S)
	return number
}
func readLineToSlice() []string {
	S := readLine()
	list := strings.Split(S, "")
	return list
}
func readLineToNumberSlice(memo map[string]int) []int {
	// err時は-1を代入
	S := readLine()
	intList := make([]int, len(S))
	for i := 0; i < len(S); i++ {
		if val, ok := memo[string(S[i])]; ok {
			intList[i] = val
		} else {
			intList[i] = -1
		}
	}
	return intList
}

Measured memory_bytes: 86032