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

namespace CSTemplete21
{
    using P = System.Drawing.Point;
    class Utls
    {
        public static int[][] int2(int x, int y)
        {

            var ret = new int[x][];
            for (var i = 0; i < x; i++)
            {
                ret[i] = new int[y];
            }
            return ret;
        }
    }


   public class Class1
    {
        public struct InputData
        {
            public int H, W;
            public P[] M;

        }
        public InputData input;
        public int[] hc, wc, hml, wml;
        public int hm, wm;
        public HashSet<P> f;

       

        static void Main()
        {
            var c = new Class1();
            c.input = c.Input();
            c.Func();

        }
        public void Func()
        {
            f = new HashSet<P>(input.M);
            hc = new int[input.H];
            wc = new int[input.W];
            foreach ( var i in  input.M)
            {
                int m;
                hc[i.Y]++;
                m = hc[i.Y];
                if ( hm < hc[i.Y])
                {
                    hm = m;
                }
                wc[i.X]++;
                m = wc[i.X];
                if( wm < m)
                {
                    wm = m;
                }
            }

            hc = hc.Select((n, idx) =>
            {
                if (n == hm)
                {
                    return idx;
                }
                else
                {
                    return -1;
                }
            }).ToArray();
            hml = hc.Where((n) =>
            {
                return n != -1;
            }).ToArray();

            wc = wc.Select((n, idx) =>
            {
                if (n == wm)
                {
                    return idx;
                }
                else
                {
                    return -1;
                }
            }).ToArray();
            wml = wc.Where((n) =>
            {
                return n != -1;
            }).ToArray();

            var t = new P();

            var ret = hm + wm - 1;
            var cont = true;
            foreach ( var i in hml)
            {
                foreach(var j in wml)
                {
                    t.Y = i;
                    t.X = j;
                    if (!f.Contains(t))
                    {
                        ret++;
                        cont = false;
                         
                    }
                    if (!cont)
                    {
                        break;
                    }
                }
                if (!cont)
                {
                    break;
                }
            }

            Console.WriteLine(ret);



        }

        public dynamic Input()
        {
            var ret = new InputData();

            var l = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            ret.H = l[0];
            ret.W = l[1];
            var m =  l[2];
            ret.M = new P[m];

            for ( var i = 0; i< m; i++)
            {
                l = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
                ret.M[i] = new P(l[1] - 1, l[0] - 1);

            }

            return ret;
        }


    }
}


Measured memory_bytes: 71632