#include <iostream>
using namespace std;
int main (){
while (1){
int a[10001],b[10001],c[501]={0},n,m,d=0;
cin>>n>>m;
if (n==0&&m==0)break;
c[1]=1;
for (int s=0;s<m;s++){
        cin>>a[s]>>b[s];
        if (a[s]==1){
                c[b[s]]=2;
        }
}
for (int s=0;s<m;s++){
        if (c[a[s]]==2&&c[b[s]]==0){
                c[b[s]]=3;
        }
        if (c[a[s]]==0&&c[b[s]]==2){
                c[a[s]]=3;
        }
}
for (int s=2;s<=n;s++){
        if (c[s]!=0){
                d++;
        }
}
cout<<d<<endl;
}
return 0;
}