import sys
# from collections import deque
input = sys.stdin.readline
n = int(input())
m = int(input())
adj = [[] for _ in range(n+1)]
inv = [0]*(n+1)
ans = 0
for _ in range(m):
a, b = map(int, input().split())
adj[a].append(b)
adj[b].append(a)
for friend in adj[1]:
inv[friend] = 1
for f in adj[friend]:
inv[f] = 1
for i in range(n+1):
if i == 1: continue
if inv[i] == 1: ans += 1
print(ans)