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
import java.io.IOException;
import java.io.InputStream;
import java.util.HashSet;
import java.util.NoSuchElementException;
 
public class Main {
	private static FastScanner sc = new FastScanner();
	private static Node[] V;
	static int Xn;
	static int Yn;
	static int s;
	static int ed;
	
	public static void main(String[] args) {
		Xn = sc.nextInt();
		Yn = sc.nextInt();
		s = Xn + Yn;
		ed = Xn + Yn + 1;
		int En = sc.nextInt();
		
		V = new Node[Xn + Yn + 2];
		for(int i=0; i<V.length; i++) {
			V[i] = new Node();
			V[i].id = i;
		}
		
		for(int i=0; i<En; i++) {
			int x = sc.nextInt();
			int y = sc.nextInt() + Xn;
			V[x].nbr.add(new Edge(y, 1));
			V[y].nbr.add(new Edge(x, 0));
		}
		
		for(int i=0; i<Xn; i++) {
			V[s].nbr.add(new Edge(i, 1));
			V[i].nbr.add(new Edge(s, 0));
		}
		
		for(int i=Xn; i<Xn+Yn; i++) {
			V[i].nbr.add(new Edge(ed, 1));
			V[ed].nbr.add(new Edge(i, 0));
		}
		
		int flow = 0;
		while(true) {
			for(int i=0; i<V.length; i++) {
				V[i].used = false;
			}
			int f = V[s].dfs(Integer.MAX_VALUE);
			if (f == 0) {
				System.out.println(flow);
				return;
			}
			flow += f;
		}
	}
	
	static class Node {
		int id;
		boolean used;
		HashSet<Edge> nbr = new HashSet<>();
		
		int dfs (int f) {
			if(id == ed) {
				return f;
			}
			used = true;
			for(Edge e : nbr) {
				if(!V[e.t].used && e.c > 0) {
					int d = V[e.t].dfs(Math.min(f, e.c));
					if(d > 0) {
						e.c -= d;
						for(Edge e2 : V[e.t].nbr) {
							if(e2.t == id) {
								e2.c += d;
								break;
							}
						}
						
						return d;
					}
				}
			}
			
			return 0;
		}
	}
	
	static class Edge {
		int t;
		int c;
		Edge(int t, int c) {
			this.t = t;
			this.c = c;
		}
	}
	
	static class FastScanner {
        private final InputStream in = System.in;
        private final byte[] buffer = new byte[1024];
        private int ptr = 0;
        private int buflen = 0;
        private boolean hasNextByte() {
            if(ptr < buflen) {
                return true;
            } else {
                ptr = 0;
                try {
                    buflen = in.read(buffer);
                } catch(IOException e) {
                    e.printStackTrace();
                }
                if(buflen <= 0) {
                    return false;
                }
            }
            return true;
        }
        private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
        private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
        private void skipUnprintable() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;}
        public boolean hasNext() { skipUnprintable(); return hasNextByte();}
        public String next() {
            if (!hasNext()) throw new NoSuchElementException();
            StringBuilder sb = new StringBuilder();
            int b = readByte();
            while(isPrintableChar(b)) {
                sb.appendCodePoint(b);
                b = readByte();
            }
            return sb.toString();
        }
        public long nextLong() {
            return Long.parseLong(next());
        }
        public int nextInt(){
            return Integer.parseInt(next());
        }
        public double nextDouble(){
            return Double.parseDouble(next());
        }
    }
}