#include using namespace std; using llong = long long; using ldbl = long double; using lpair = pair; #define ALL(x) x.begin(), x.end() constexpr llong mod = 1e9+7; constexpr llong inf = mod * mod; struct dinic { struct edge { long long to; long long cap; long long rev; edge(long long to, long long cap, long long rev) : to(to), cap(cap), rev(rev) {} }; std::vector > edges; std::vector level; std::vector iter; dinic() {} dinic(int N) : edges(N+1), level(N+1), iter(N+1) {} void add_edge(long long from, long long to, long long cap) { edges[from].push_back(edge(to, cap, edges[to].size())); edges[to].push_back(edge(from, 0, edges[from].size()-1)); } void bfs(long long s) { fill_n(level.begin(), level.size(), -1); level[s] = 0; std::queue q; q.push(s); while (q.size()) { long long now = q.front(); q.pop(); for (int i = 0; i < edges[now].size(); i++) { edge next = edges[now][i]; if (next.cap > 0 && level[next.to] == -1) level[next.to] = level[now] + 1, q.push(next.to); } } } long long dfs(long long s, long long t, long long flow) { if(s == t) return flow; while(iter[s] < edges[s].size()) { edge &next = edges[s][iter[s]]; if (next.cap > 0 && level[next.to] > level[s]) { long long d = dfs(next.to, t, std::min(flow, next.cap)); if (d > 0) { next.cap -= d; edges[next.to][next.rev].cap += d; return d; } } iter[s]++; } return 0; } long long max_flow(long long s, long long t) { long long inf = 1e9; long long ret = 0; while (true) { bfs(s); if (level[t] < 0) return ret; fill_n(iter.begin(), iter.size(), 0); long long f; while (f = dfs(s, t, inf), f > 0) ret += f; } } }; int main() { llong N, M; cin >> N >> M; dinic d(4 * N + 1); for (int i = 0; i < M; i++) { llong A, B; cin >> A >> B; d.add_edge(A, 2 * N + B, 1); d.add_edge(B, 2 * N + A, 1); } for (int i = 1; i <= 2 * N; i++) { d.add_edge(0, i, 1); d.add_edge(2 * N + i, 4 * N + 1, 1); } cout << N - d.max_flow(0, 4 * N + 1) / 2; return 0; }