from collections import deque
def bfs(x):
global count
visited[x] = 1
q.append(x)
while q:
x = q.popleft()
for i in range(len(a[x])):
w = a[x][i]
if (visited[w] != 1):
visited[w] =1
count +=1#인접한곳을 갈때마다 count를 1씩 증가시켜서 연결된것이 전부 몇개인지 확인해준다.
q.append(w)
node = int(input())
edge = int(input())
a =[ [] for _ in range(node+1)]
visited =[ 0 for _ in range(node +1)]
count = 0
q = deque()
for i in range(edge):
x,y = map(int, input().split())
a[x].append(y)
a[y].append(x)
bfs(1)#BFS 시작
print(count)