#include<iostream>
#include<string.h>
using namespace std;
long long r[501][1001]={0};
int s[501]={0};
int ans=0,n;
void takahashi(int i){
	//cout<<i<<endl;
	for(int j=2;j<=n;j++){
		if(r[i][j]==1&&s[j]!=1&&r[1][j]!=1){
			s[j]=1;
			ans++;
		}
	}
}	
int main(){
	while(1){
		int m,a,b;
		ans=0;
		cin>>n>>m;
		if(n==0&&m==0)break;
		memset(r,0,sizeof(r));
		memset(s,0,sizeof(s));
		s[1]=1;
		for(int i=0;i<m;i++){
			cin>>a>>b;
			r[a][b]=1;
			r[b][a]=1;
		}
		/*for(int i=1;i<=n;i++){
			for(int j=1;j<=n;j++){
				cout<<r[i][j];
			}
			cout<<endl;
		}*/
		for(int i=2;i<=n;i++){
			if(r[1][i]==1){
				s[i]=1;
				ans++;
				takahashi(i);
			}
		}
		cout<<ans<<endl;
	}
}