#include<bits/stdc++.h>
#define eho(X,x) for(int i=X.head[x];i;i=X.net[i])
#define v G1.fall[i]
#define V G2.fall[i]
#define N 100007
#define pii pair<int,int>
using namespace std;
int n,col[N],nwa[N],nwb[N],cnt,low[N],dfn[N],cn1,usd[N<<1],op;
map<pii,int> ma;
struct Graph{
int tot,head[N],net[N<<1],fall[N<<1];
Graph() {tot=1;}
void add(int x,int y){
fall[++tot]=y; net[tot]=head[x]; head[x]=tot;
}
void adds(int x,int y){add(x,y); add(y,x);}
}G1,G2;
int s[N],tp;
int m,x,y,color,ans,us2[N],lef,alg,dis[N],top,he,siz,XX,YY;
void tarjan(int x,int f) {
dfn[x]=low[x]=++cnt,s[tp++]=x;
eho(G1,x) if (v!=f) {if (!dfn[v]) tarjan(v,x);low[x]=min(low[x],low[v]);}
if (low[x]==dfn[x]) { color++;do {col[s[--tp]]=color;}while (s[tp]!=x);}
}
//void tarjan(int x,int f_eg) {
// dfn[x]=low[x]=++cnt;
// eho(G1,x) {
// if (!dfn[v]) {
// tarjan(v,i);
// low[x]=min(low[x],low[v]);
// if (low[v]>low[x]) {
// usd[i]=usd[i^1]=1; nwa[++cn1]=G1.fall[i]; nwb[cn1]=G1.fall[i^1];
// }
// } else if (i^f_eg^1) low[x]=min(low[x],dfn[v]);
// }
//}
//void dfs(int x,int color) {
// col[x]=color;
// eho(G1,x) if (!usd[i]&&!col[v]) dfs(v,color);
//}
void Dfs2(int x,int fa){
int alg=!!fa;
us2[x]=1;
eho(G2,x) if (V^fa) {
alg++; Dfs2(V,x);
}
lef+=alg<=1;
}
void Dfs(int x,int fa){
// cerr<<x<<endl;
dis[x]=dis[fa]+1;
eho(G2,x) if (V^fa) Dfs(V,x);
if (dis[x]>dis[top]) top=x;
}
void work(int x) {
lef=0; siz++;
Dfs2(x,0);
top=0,Dfs(x,0); he=top;
top=0,Dfs(he,0);
ans+=dis[top]>1?lef+dis[top]-2:1;
op+=lef;
}
signed main () {
freopen("merge.in","r",stdin);
freopen("merge.out","w",stdout);
scanf("%d%d",&n,&m);
for (int i=1;i<=m;i++) {
scanf("%d%d",&x,&y);
G1.adds(x,y);
}
for (int i=1;i<=n;i++) if (!dfn[i]) tarjan(i,0);
// for (int i=1;i<=n;i++) {
// if (col[i]) continue;
// dfs(i,++color);
// }
int pi=0;
// assert(p)
// for (int i=1;i<=cn1;i++) {
// XX=col[nwa[i]]; YY=col[nwb[i]];
// if (XX>YY) swap(XX,YY);
// if (ma.count(pii(XX,YY))) continue;
// G2.adds(XX,YY);
// ma[pii(XX,YY)]=1; pi++;
// }
// assert(cn1==pi);
for (int j=1;j<=n;j++) eho(G1,j) if (col[j]!=col[v]) G2.add(col[j],col[v]),pi++;
// cerr<<pi<<endl;
for (int i=1;i<=color;i++) if (!us2[i]) work(i);
printf("%d\n",n-ans+siz-1);
// cerr<<pi/2+siz<<endl;
cerr<<op<<endl;
// assert(pi+siz-1==color);
return 0;
}