对于一棵无向树,我们要使得其变成边双连通图,需要添加的边数 == (树中度数为1的点的个数+1)/2
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string.h>
#include<string>
#include<vector>
#include<map>
#include<queue>
#include<stack>
#include<math.h>
#include<set>
#define N 5010
using namespace std;
struct node
{
int v, nxt;
}e[4*N];
int head[N], cnt;
int dfn[N], low[N], vis[N], ti;
void init()
{
memset(head, 0, sizeof(head));
memset(dfn, 0, sizeof(dfn));
memset(low, 0, sizeof(low));
memset(vis, 0, sizeof(vis));
ti = 0, cnt = 1;
}
void add(int u,int v)
{
e[++cnt].v = v;
e[cnt].nxt = head[u];
head[u] = cnt;
}
void tarjan(int u, int fa)
{
dfn[u] = low[u] = ++ti;
for (int i = head[u]; i; i = e[i].nxt)
{
if (i == (fa ^ 1))continue;
int v = e[i].v;
//if (v == fa)continue;
if (!dfn[v])
{
//tarjan(v, u);
tarjan(v,i);
low[u] = min(low[u], low[v]);
}
else low[u] = min(low[u], dfn[v]);
}
}
int main()
{
int n, m;
int u, v;
while (~scanf("%d%d", &n, &m))
{
init();
while (m--)
{
scanf("%d%d", &u, &v);
add(u, v);
add(v, u);
}
tarjan(1, -1);
for (int u = 1; u <= n; u++)
{
for (int i = head[u]; i; i = e[i].nxt)
{
v = e[i].v;
if (low[u] != low[v])
{
vis[low[v]]++;
}
}
}
int ans = 0;
for (int i = 1; i <= n; i++)
{
if (vis[i] == 1)ans++;
}
printf("%d\n", (ans + 1) / 2);
}
return 0;
}