#include <stdio.h>
#include <vector>

using namespace std;

int main(void){
	while(true){
		int n, m, t1, t2;
		scanf("%d\n%d", &n, &m);
		if(n == 0 && m == 0) return 0;

		vector< vector<int> > G;

		for(int i = 0;i < n;++i){
			vector<int> V;
			G.push_back(V);
		}

		for(int i = 0;i < m;++i){
			scanf("%d %d", &t1, &t2);
			G[t1-1].push_back(t2-1);
			G[t2-1].push_back(t1-1);
		}

		vector<int> guests(n, 0);

		for(int i = 0;i < G[0].size();++i){
			guests[G[0][i]] = 1;
			for(int j = 0;j < G[G[0][i]].size();++j){
				guests[G[G[0][i]][j]] = 1;
			}
		}

		int c = 0;
		for(int i = 1;i < n;++i){
			c += guests[i];
		}

		printf("%d\n", c);
	}
}

#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
int main(){
  int n,m,ans=0;
  cin >> n >> m;
  while(n!=0||m!=0){
    ans = 0;
    n++;
    vector<int>a(m,0),b(m,0),hito(n,0),one(n,0);
    rep(i,m){
      cin>>a[i]>>b[i];
      if(a[i]==1){
	hito[b[i]]++;
	one[b[i]]++;
      }
      if(b[i]==1){
	hito[a[i]]++;
	one[a[i]]++;
      }
    }
    rep(i,n){
      if(i==0||i==1)continue;
      rep(j,m){
	if(one[i]!=0){
	  if(i==a[j])hito[b[j]]++;
	  if(i==b[j])hito[a[j]]++;
	}
      }
    }
    rep(i,n){
      if(i==0||i==1)continue;
      if(hito[i]!=0){
	ans++;
      }
    }
    cout<<ans<<endl;
    cin >> n >> m;
  }
  return (0);
}