看题解会的系列……
详细解释先坑着,以后补……
#include<bits/stdc++.h>
#define N 200005
using namespace std;
int head[N],ans=,tot=,cnt=,n,m,vis[N];
struct Edge{int u,v,next;}G[N<<];
inline void addedge(int u,int v){
G[++tot].u=u;G[tot].v=v;G[tot].next=head[u];head[u]=tot;
G[++tot].u=v;G[tot].v=u;G[tot].next=head[v];head[v]=tot;
}
inline int read(){
int f=,x=;char ch;
do{ch=getchar();if(ch=='-')f=-;}while(ch<''||ch>'');
do{x=x*+ch-'';ch=getchar();}while(ch>=''&&ch<='');
return f*x;
}
void dfs(int u){
vis[u]=;
for(int i=head[u];i;i=G[i].next,cnt++){
int v=G[i].v;
if(!vis[v])dfs(v);
}
}
int main(){
m=read();n=read();
for(int i=;i<=m;i++){
int u=read(),v=read();
addedge(u,v);
}
for(int i=;i<=n;i++){
if(!vis[i]){
cnt=;dfs(i);
ans+=((cnt>>)&);
}
}
printf("%d\n",ans);
}