h, w, m = gets.split.map(&:to_i)
target_list = []
h_map = {}
w_map = {}

class TargetInfo
    attr_accessor :h, :w

    def to_s
        puts "#{h}_#{w}"
    end
end

m.times do |i|
    hx, wx = gets.split.map(&:to_i)
    target = TargetInfo.new
    target.h = hx
    target.w = wx
    target_list << target
    h_map[hx.to_s] ||= []
    h_map[hx.to_s] << target
    w_map[wx.to_s] ||= []
    w_map[wx.to_s] << target
end

max_h_list = []
max = 0
h_map.each_key do |key|
    if h_map[key].size > max
        max_h_list = []
        max = h_map[key].size
    end
    max_h_list << h_map[key] if h_map[key].size == max
end

max = 0
max_w_list = []
w_map.each_key do |key|
    if w_map[key].size > max
        max_w_list = []
        max = w_map[key].size
    end
    max_w_list << w_map[key] if w_map[key].size == max
end

max_target = max_w_list[0].size + max_h_list[0].size - 1

max_h_list.each do |h_list|
    temp_map = {}
    h_list.each do |info|
        temp_map["#{info.h}_#{info.w}"] = true
    end
    max_w_list.each do |w_list|
        exist = false
        w_list.each do |w_info|
            if temp_map["#{w_info.h}_#{w_info.w}"]
                exist = true
                break
            end
        end
        unless exist
            max_target = max_w_list[0].size + max_h_list[0].size
            break
        end
    end
end

puts max_target
