#include #include #include #include #include #include using namespace std; const int maxn = 150; int graph[maxn][maxn]; bool visited[maxn]; int match[maxn]; int n; bool dfs(int node) { for(int i = 0; i < maxn; i++) { if(graph[node][i] == 1 and !visited[i]) { visited[i] = true; if(match[i] == -1 or dfs(match[i])) { match[i] = node; return true; } } } return false; } int maximum_bipartite_matching() { memset(match, -1, sizeof match); int result = 0; for(int i = 0; i < n; i++) { memset(visited, false, sizeof visited); if(dfs(i) == true) { result++; } } return result; } int main() { int m; cin >> n >> m; memset(graph, 0, sizeof graph); for(int i = 0; i < m; i++) { int a, b; cin >> a >> b; graph[a][b] = 1; } cout << maximum_bipartite_matching() << endl; return 0; } /* 10 9 1 6 1 9 1 10 2 6 2 7 3 7 4 8 4 9 5 10 */