using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	const int L = (int) 3e5 + 20;
	public void Solve(){
		
		int ma = -1;
		var ST = new SegTreeMax(L);
		
		var di = new Dictionary<int,List<int>>();
		for(int i=0;i<M;i++){
			if(!di.ContainsKey(W[i])) di.Add(W[i], new List<int>());
			di[W[i]].Add(H[i]);
			ST.Add(H[i], 1);
		}
		
		foreach(var w in di.Keys){
			int cnt = di[w].Count;
			foreach(var h in di[w]){
				ST.Add(h, -1);
			}
			cnt += ST.Max;
			ma = Math.Max(ma, cnt);
			foreach(var h in di[w]){
				ST.Add(h, +1);
			}
		}
		
		ST = new SegTreeMax(L);
		di = new Dictionary<int,List<int>>();
		for(int i=0;i<M;i++){
			if(!di.ContainsKey(H[i])) di.Add(H[i], new List<int>());
			di[H[i]].Add(W[i]);
			ST.Add(W[i], 1);
		}
		
		foreach(var h in di.Keys){
			int cnt = di[h].Count;
			foreach(var w in di[h]){
				ST.Add(w, -1);
			}
			cnt += ST.Max;
			ma = Math.Max(ma, cnt);
			foreach(var w in di[h]){
				ST.Add(w, +1);
			}
		}
		
		Console.WriteLine(ma);
		
		
	}
	int HH, WW, M;
	int[] H, W;
	public Sol(){
		var d = ria();
		HH = d[0]; WW = d[1]; M = d[2];
		H = new int[M];
		W = new int[M];
		for(int i=0;i<M;i++){
			d = ria();
			H[i] = d[0]; W[i] = d[1];
		}
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}


class SegTreeMax{
	//segment Tree 
	// 0-origin
	protected int[] Data;	
	protected int Inf;	
	protected int N;		 
	protected int n;		
	
	public SegTreeMax(int n_){
		N = n_; Inf = -(int)1e9;
		Inf = 0;
		n = 1;
		while(n < n_) n *= 2;
		Data = new int[2 * n - 1];
		for(int i=0; i < 2 * n - 1; i++) Data[i] = Inf;
	}
	
	//	   0
	//	 1   2
	//	3 4 5 6
	public void Update(int k,int a){
		k += n - 1;	
		Data[k] = a;
		while(k > 0){
			k = (k - 1) / 2;
			Data[k] = Math.Max(Data[k * 2 + 1], Data[k * 2 + 2]);
		}
	}
	public void Add(int k,int a){
		k += n - 1;	
		Data[k] += a;
		while(k > 0){
			k = (k - 1) / 2;
			Data[k] = Math.Max(Data[k * 2 + 1], Data[k * 2 + 2]);
		}
	}
	
	
	public int QueryMax(int a, int b){
		return Query(a, b, 0, 0, n);
	}
	//RMQ; [a,b)
	public int Query(int a,int b,int k,int l,int r){
		if(r <= a || b <= l) return Inf;
		if(a <= l && r <= b) return Data[k];
		
		var vl = Query(a, b, k * 2 + 1, l, (l + r) / 2);
		var vr = Query(a ,b, k * 2 + 2, (l + r) / 2, r);
		return Math.Max(vl, vr);
	}
	
	
	public int Max{
		get{ return Data[0];}
	}
	
	
	public void Dump(){
		Console.WriteLine();
		int h = 0;
		int cnt = 0;
		for(int i=0;i<Data.Length;i++){
			Console.Write("{0} ", Data[i]);
			cnt++;
			if(cnt == 1 << h){
				cnt = 0;
				h++;
				Console.WriteLine();
			}
		}
	}
	
}



Measured memory_bytes: 107848