#include <iostream>
#include <cstdio>
#include <string.h>
using namespace std;

int main(){
  int n,m;
  while(cin >> n >> m , n+m){
    cin.clear();
    int a,b;
    int cne[501][501] = {{0}};
    for(int i = 0 ; i < m ; i++){
      cin >> a >> b;
      if(a > b)swap(a,b);
      cne[a][b] = 1;
      cne[b][a] = 1;
    }
    int f[501] = {0};
    int cnt = 0;
    for(int i = 1 ; i <= n ; i++){
      if(cne[1][i]){
	f[i] = 1; 
	for(int j = 2 ; j <= n ; j++ ){
	  if(cne[i][j]){
	    f[j] = 1;
	  }
	}
      }
    }
    for(int i = 1 ; i <= n ; i++ ){
      if(f[i])cnt++;
}
    cout << cnt << endl;

  }
  return 0;
}