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

public class AtCoderA
{
    static void Main()
    {
        var sc = new Scanner();

        long h = sc.NextLong();
        long w = sc.NextLong();
        long m = sc.NextLong();

        Tuple<long, long>[] targets = new Tuple<long, long>[m];

        long[] countH = new long[h + 1];
        long[] countW = new long[w + 1];
        SortedSet<long>[] wInH = new SortedSet<long>[h + 1];
        for (int i = 0; i <= h; i++)
        {
            wInH[i] = new SortedSet<long>();
        }

        for (int i = 0; i < m; i++)
        {
            long h1 = sc.NextLong();
            long w1 = sc.NextLong();
            targets[i] = Tuple.Create(h1, w1);
            wInH[h1].Add(w1);
            countH[h1]++;
            countW[w1]++;
        }

        long maxH = countH.Max();
        long maxW = countW.Max();

        SortedSet<long> hs = new SortedSet<long>();
        SortedSet<long> ws = new SortedSet<long>();

        for (int i = 0; i < m; i++)
        {
            var t = targets[i];
            if (countH[t.Item1] == maxH)
            {
                hs.Add(t.Item1);
            }
            if (countW[t.Item2] == maxW)
            {
                ws.Add(t.Item2);
            }
        }

        bool exist = true;
        if (hs.Count() * ws.Count() > 300000)
        {
            exist = false;
        }
        else
        {
            foreach (var hh in hs)
            {
                var list = wInH[hh];
                if (list.Count < ws.Count)
                {
                    exist = false;
                    break;
                }
                foreach (var ww in ws)
                {
                    if (!list.Contains(ww))
                    {
                        exist = false;
                        break;
                    }
                }
                if (exist == false)
                {
                    break;
                }
            }
        }

        long answer = countH.Max() + countW.Max();
        if (exist)
        {
            answer--;
        }

        Console.WriteLine(answer);
    }

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            while (_index >= _line.Length)
            {
                _line = Console.ReadLine().Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            _line = Console.ReadLine().Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}


Measured memory_bytes: 124496