#include<cstdio>
#include<queue>
#include<cstring>
using namespace std;

#define REP(i,a,b) for(i=a; i<b; ++i)
#define rep(i,n) REP(i,0,n)

int graph[500][500],dist[500];

int main() {
  int n,m,i,j,k,a,b;
  for(;;) {
    scanf("%d", &n);
    scanf("%d", &m); if(!n) break;
    memset(graph, 0, sizeof(graph));
    memset(dist, 0, sizeof(dist));
    rep(i,m) {
      scanf("%d %d", &a, &b);
      graph[a-1][b-1] = graph[b-1][a-1] = 1;
    }

    queue<int> Q;
    int ans = 0;
    dist[0] = 1;
    Q.push(0);
    while(!Q.empty()) {
      int now = Q.front(); Q.pop();
      ans++;
      if(dist[now] >= 3) continue;
      rep(i,n) {
	if(dist[i] != 0 || graph[now][i] == 0) continue;
	dist[i] = dist[now]+1;
	Q.push(i);
      }
    }

    printf("%d\n", ans-1);
  }
}