#include<iostream>
#include<vector>
using namespace std;
#define MAX_N 1000
vector<int> G[MAX_N];
int visited[MAX_N];
int n,m,ans;

void dfs(int pos,int depth){
  if(depth==3)return;
  if(!visited[pos])ans++;
  visited[pos]=true;
  for(int i=0;i<(int)G[pos].size();i++){
    int w=G[pos][i];
    dfs(w,depth+1);
  }
}

void init(){
  for(int i=0;i<MAX_N;i++)G[i].clear(),visited[i]=false;
}
int main(){
  while(cin>>n>>m&&n&&m){
    init();
    for(int i=0;i<m;i++){
      int a,b;
      cin>>a>>b;
      G[a].push_back(b);
      G[b].push_back(a);
    }
    ans=0;
    dfs(1,0);
    cout<<ans-1<<endl;
  }
  return 0;
}