#!/usr/bin/env ruby



$visited = []
$pre_vertex = []


def min a,b
  if a<b then return a else b end
end

def init_dfs v,e
  $visited = Array.new(v,false)
  $pre_vertex = Array.new(v,false)
end

#b -> e ??§edges
def dfs b,e,es
  es[b].each_with_index do |c,v|
    if !$visited[v] and c>0 then
      $visited[v] = true
      $pre_vertex[v] = b
      if v==e then
        return
      end
      dfs(v,e,es)
    end
  end
end


def back_trace b,e,es
  flow =[]
  min_c = 10e8

  to = e
  from = $pre_vertex[e]
  flow=[[from,to]]+flow
  min_c = min(min_c,es[from][to])

  while from != b
    to = from
    from = $pre_vertex[from]
    flow=[[from,to]]+flow
    min_c = min(min_c,es[from][to])
  end
  return flow,min_c
end



#v_size,e_size = gets.chomp.split(/ /).map{|i| i.to_i}

x_size,y_size,e_size = gets.chomp.split(/ /).map{|i| i.to_i}

edges = Array.new(x_size+y_size+2).map{ Array.new(x_size+y_size+2,0)}


e_size.times do
  u,v = gets.chomp.split(/ /).map{|i| i.to_i}
  edges[u][v] = 1
end
x_size.times do |i|
  edges[x_size+y_size][i] = 1
end
y_size.times do |i|
  edges[i][x_size+y_size+1] = 1
end

@ans = 0
v_size = x_size+y_size+2
loop do

  init_dfs(v_size,e_size)
  dfs(x_size+y_size,x_size+y_size+1,edges)
  if $visited[v_size-1] then
    f,min_c = back_trace(x_size+y_size,x_size+y_size+1,edges)
    f.each do |i|
      edges[i[0]][i[1]]=0
      edges[i[1]][i[0]]=1
    end
    @ans = @ans+ min_c
  else
    p @ans
    break
  end
end