题意:
计算图中不公共边的环的个数
//存不存在单环,不公边的环
#include<bits/stdc++.h>
#define inf 0x3f3f3f3f
#define maxn 300010
#define sf scanf
#define pf printf
using namespace std;
vector <int> G[maxn];
vector <int> ve;
int n,m,x,y,vis[maxn],ans,flag;
//遍历和当前点相连的点
void dfs(int x){vis[x]=1;ve.push_back(x);for(int i=0;i<G[x].size();i++){if(!vis[G[x][i]]){dfs(G[x][i]);}}
}
int main(){sf("%d%d",&n,&m);for(int i=0;i<m;i++){sf("%d%d",&x,&y);G[x].push_back(y);G[y].push_back(x);}for(int i=1;i<=n;i++){if(!vis[i]){ve.clear();dfs(i);flag=true;for(int j=0;j<ve.size();j++){if(G[ve[j]].size()!=2){flag=false;break;}}if(flag) ans++;}}cout<<ans<<endl;return 0;
}