#include <cstdio>
#include <algorithm>
using namespace std;
int network[105][105]={};
int visited[105]={};
int vc=0;
int n,m;
void f(int c)
{
visited[c]=1;
for(int i=1; i<=n; i++)
{
if(network[c][i]==1 && visited[i]==0)
{
vc++;
f(i);
}
}
return;
}
int main()
{
scanf("%d %d",&n,&m);
for(int i=0; i<m; i++)
{
int a,b;
scanf("%d %d", &a, &b);
network[a][b]=1;
network[b][a]=1;
}
f(1);
printf("%d",vc);
return 0;
}
To embed this project on your website, copy the following code and paste it into your website's HTML: