Given an undirected graph with N vertices and M edges, print the size of a maximum matching.
A graph with NNN vertices and MMM undirected edges is given. Write a program that prints the size of a maximum matching of that graph.
In a graph G=(V,E)G = (V, E)G=(V,E) (∣V∣=N|V| = N∣V∣=N, ∣E∣=M|E| = M∣E∣=M), a matching TTT is a subset of EEE in which no two elements share a vertex.
A maximum matching is a matching of the largest possible size.
The first line contains the number of vertices NNN (1≤N≤5001 \le N \le 5001≤N≤500) and the number of edges MMM (1≤M≤1247501 \le M \le 1247501≤M≤124750).
Each of the next MMM lines describes one edge.
An edge is described by the numbers of the two distinct vertices it joins.
Every vertex number is a natural number between 111 and NNN.
At most one edge joins any given pair of vertices.
Print the size of a maximum matching on the first line.