from collections import deque
n=int(input())
m=int(input())
graph=[[] for _ in range(n+1)]
for i in range(m):
u,v=map(int,input().split())
graph[u].append(v)
graph[v].append(u)
vis = [False] * (n+1)
dq = deque()
dq.append(1)
vis[1] = True
while dq:
cur = dq.popleft()
for next in graph[cur]:
if vis[next] == False:
vis [next] = True
dq.append(next)
print(vis.count(True)-1)
To embed this project on your website, copy the following code and paste it into your website's HTML: