func_code_string: #include <bits/stdc++.h>   using namespace std;   const int mn = 2005;   vector<int> g[mn], G[mn];   int dfn[mn], low[mn], times;   int stk[mn], top, bel[mn], cnt, siz[mn], fa[mn];   int rt, maxs;   bool ins[mn], vis[mn][mn], flg[mn], chn[mn], tmp[mn], leav[mn];   void dfs1(int s, int f) {     dfn[s] = low[s] = ++times, stk[++top] = s, ins[s] = 1;     int m = g[s].size();     for (int i = 0; i < m; i++) {       int t = g[s][i];       if (t == f) continue;       if (!dfn[t])         dfs1(t, s), low[s] = min(low[s], low[t]);       else if (ins[s])         low[s] = min(low[s], dfn[t]);       if (low[t] > dfn[s]) {         ++cnt;         while (stk[top] != t)           ins[stk[top]] = 0, bel[stk[top--]] = cnt, ++siz[cnt];         bel[t] = cnt, ins[t] = 0, --top, ++siz[cnt];       }     }   }   void dfs2(int s, int d) {     if (d > maxs) rt = s, maxs = d;     int m = G[s].size();     flg[s] = 1;     for (int i = 0; i < m; i++) {       int t = G[s][i];       if (!flg[t]) dfs2(t, d + 1);     }   }   void dfs3(int s, int f, int d) {     int m = G[s].size();     fa[s] = f;     bool flg = 0;     for (int i = 0; i < m; i++) {       int t = G[s][i];       if (t != f) dfs3(t, s, d + 1), flg = 1;     }     leav[s] = flg ^ 1;     if (!flg && d > maxs) {       memset(tmp, 0, sizeof tmp), maxs = d;       while (s) tmp[s] = 1, s = fa[s];     }   }   int main() {     int n, m, a, b, blk = 0, ans = 0;     scanf( %d%d , &n, &m);     for (int i = 1; i <= m; i++)       scanf( %d%d , &a, &b), g[a].push_back(b), g[b].push_back(a);     for (int i = 1; i <= n; i++)       if (!dfn[i]) {         dfs1(i, 0), ++blk, ++cnt;         while (top) bel[stk[top]] = cnt, ins[stk[top]] = 0, --top, ++siz[cnt];       }     for (int i = 1; i <= n; i++) {       int siz = g[i].size();       for (int j = 0; j < siz; j++) {         int t = g[i][j];         if (bel[i] != bel[t] && !vis[bel[i]][bel[t]])           vis[bel[i]][bel[t]] = vis[bel[t]][bel[i]] = 1,           G[bel[i]].push_back(bel[t]), G[bel[t]].push_back(bel[i]);       }     }     for (int i = 1; i <= cnt; i++) {       ans += siz[i] - 1;       if (!flg[i]) {         maxs = 0, dfs2(i, 1), maxs = 0, dfs3(rt, 0, 1);         for (int i = 1; i <= cnt; i++) chn[i] |= tmp[i];       }     }     for (int i = 1; i <= cnt; i++) {       int s = i, d = 0;       if (leav[s]) continue;       while (!chn[s]) chn[s] = 1, s = fa[s], ++d;       ans += d;     }     printf( %d n , ans + blk - 1);   }   