A bipartite graph G = (V, E) is a graph in which the vertex set V can be divided into two disjoint subsets X and Y such that every edge e ∈ E has one end point in X and the other end point in Y.

A matching M is a subset of edges such that each node in V appears in at most one edge in M.

Given a bipartite graph, find the size of the matching which has the largest size.

Constraints

* 1 ≤ |X|, |Y| ≤ 100
* 0 ≤ |E| ≤ 10,000

Input


|X| |Y| |E|
x0 y0
x1 y1
:
x|E|-1 y|E|-1


|X| and |Y| are the number of vertices in X and Y respectively, and |E| is the number of edges in the graph G. The vertices in X are named with the numbers 0, 1,..., |X|-1, and vertices in Y are named with the numbers 0, 1,..., |Y|-1, respectively.

xi and yi are the node numbers from X and Y respectevely which represent the end-points of the i-th edge.

Output

Print the largest size of the matching.

Example

Input

3 4 6
0 0
0 2
0 3
1 1
2 1
2 3


Output

3
#フローに帰着、dinic法,dinic法は蟻本
import sys
from collections import deque

sys.setrecursionlimit(200000)

class Dinic:
    
    def __init__(self,v, inf =10**10):
        self.v = v
        self.inf = inf
        self.G = [[] for _ in range(v)]
        self.level = [-1]*v#深さ
        self.ite = [0]*v#DFSでの探索が済んでいるか否か
    
    def add_edge(self, fr, to, cap):#末尾はself.G[to]から対応する辺のself.G[fr]内でのindex
        self.G[fr].append([to,cap,len(self.G[to])])###{'to':to,"cap":cap,"rev";len(self.G[to})}みたいにしたほうがいいか
        self.G[to].append([fr,0,len(self.G[fr])-1])

    
    def bfs(self,s):#BFSで深さ決定,sがstart
        self.level = [-1]*self.v#必要
        self.level[s] = 0
        Q = deque()
        Q.append(s)
        while Q:
            v = Q.popleft()
            for i in range(len(self.G[v])):
                e = self.G[v][i]
                if e[1]>0 and self.level[e[0]]<0:###capacity>0かつtoの深さ未定
                    self.level[e[0]] = self.level[v]+1
                    Q.append(e[0])

        
    def dfs(self,v,t,f):#DFSで増加パス探索,v開始、t終点、総フローf
        if v==t:
            return f
        for i in range(self.ite[v],len(self.G[v])):
            self.ite[v] = i
            e = self.G[v][i]
            if e[1]>0 and self.level[v]<self.level[e[0]]:
                d = self.dfs(e[0],t,min(f,e[1]))
                if d>0:
                    e[1] -= d #cap減少
                    self.G[e[0]][e[2]][1] += d#逆辺のcap増加
                    return d
        return 0
    
    def max_flow(self,s,t):
        flow = 0
        while True:
            self.bfs(s)
            if self.level[t]<0:
                return flow
            self.ite = [0]*self.v#DFSでの探索が済んでいるか否か
            f =self.dfs(s,t,self.inf)
            while f>0:
                flow+= f
                f = self.dfs(s,t,self.inf)
            
x,y,e = map(int, input().split( ))
D = Dinic(x+y+2)
for _ in range(e):
    u,w = map(int, input().split( ))
    D.add_edge(u,w+x,1)
for i in range(x+y):
    if i<x:
        D.add_edge(x+y,i,1)
    else:
        D.add_edge(i,x+y+1,1)
ans = D.max_flow(x+y,x+y+1)
print(ans)


        
                    
