using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Numerics;
using static System.Math;

namespace CSharpSpiral {
	class Program {
		public static void Main(string[] args) {
			var sw = new StreamWriter(Console.OpenStandardOutput()) {
				AutoFlush =
#if DEBUG
			true
#else
			false
#endif
			};
			Console.SetOut(sw);
			new Program().Solve(new ConsoleInput(
#if DEBUG
			new StreamReader("../../../inputData.txt")
#else
			Console.In
#endif
			, ' '));
			Console.Out.Flush();
		}

		public void Solve(ConsoleInput cin) {
			var H = cin.ReadInt; long W = cin.ReadInt; var M = cin.ReadInt;
			var row = new int[H];
			var col = new int[W];
			var targets = new HashSet<long>();
			for(int m = 0; m < M; m++) {
				var h = cin.ReadInt - 1;
				var w = cin.ReadInt - 1;
				targets.Add(h * W + w);
				row[h]++;
				col[w]++;
			}
			var rowMax = row.Max();
			var colMax = col.Max();
			var rowMaxI = Enumerable.Range(0, H).Where(i => row[i] == rowMax).ToHashSet();
			var colMaxJ = Enumerable.Range(0, (int)W).Where(j => col[j] == colMax).ToHashSet();
			var corride = true;
			if(rowMaxI.Count() * (long)colMaxJ.Count() > M) {
				corride = false;
			} else {
				long count = 0;
				var grid = (rowMaxI.Count() * (long)colMaxJ.Count());
				foreach(var T in targets) {
					if(rowMaxI.Contains((int)(T / W)) && colMaxJ.Contains((int)(T % W))) {
						count++;
					}
					if(count >= grid) goto Ultimate;
				}
				corride = count >= grid;
			}
		Ultimate:
			Console.WriteLine(rowMax + colMax - (corride ? 1 : 0));
		}

	}

	static class ExtendClass {
		public static string Join<T>(this IEnumerable<T> X, string separator = " ")
			=> string.Join(separator, X);
	}
	class ConsoleInput {
		private readonly TextReader _stream;
		private readonly char _separator = ' ';
		private readonly Queue<string> inputStream;
		public ConsoleInput(TextReader stream, char separator = ' ') {
			this._separator = separator;
			this._stream = stream;
			inputStream = new Queue<string>();
		}
		public string Read {
			get {
				if(inputStream.Count != 0) return inputStream.Dequeue();
				string[] tmp = _stream.ReadLine().Split(_separator);
				for(int i = 0; i < tmp.Length; ++i)
					inputStream.Enqueue(tmp[i]);
				return inputStream.Dequeue();
			}
		}
		public string ReadLine { get { return _stream.ReadLine(); } }
		public int ReadInt { get { return int.Parse(Read); } }
		public long ReadLong { get { return long.Parse(Read); } }
		public double ReadDouble { get { return double.Parse(Read); } }
		public string[] ReadStrArray(long N) {
			var ret = new string[N];
			for(long i = 0; i < N; ++i)
				ret[i] = Read;
			return ret;
		}
		public int[] ReadIntArray(long N) { var ret = new int[N]; for(long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
		public long[] ReadLongArray(long N) { var ret = new long[N]; for(long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
		public double[] ReadDoubleArray(long N) { var ret = new double[N]; for(long i = 0; i < N; ++i) ret[i] = ReadDouble; return ret; }
		public bool isEOF {
			get { return _stream.Peek() == -1; }
		}
	}

	static class Extend {
		public static string Join<T>(this IEnumerable<T> X, string separator = " ")
		=> string.Join(separator, X);
	}
}


Measured memory_bytes: 65000