#include<bits/stdc++.h>
using namespace std;

int main() {

  int n, m;
  while( cin >> n, n ) {
    int  student[n+1]; // 2:friend 1:friends_frined 0:others
    for(int i=1; i<=n; i++) student[i] = 0;
    cin >> m;
    int a[m+1], b[m+1];
    for(int i=0; i<m; i++) {
      cin >> a[i] >> b[i];
      if( a[i] == 1 ) student[b[i]] = 2;
    }

    for(int i=0; i<m; i++) {
      if( student[a[i]] == 2 && student[b[i]] != 2 ) {
	student[b[i]] = 1;
      }
      else if( student[b[i]] == 2 && student[a[i]] != 2 ) {
	student[a[i]] = 1;
      }
    }

    int ans = 0;
    for(int i=2; i<=n; i++) {
      if( student[i] > 0 ) ans++;
    }

    cout << ans << endl;
  }
}
#include <iostream>
#include <vector>
#include <set>
using namespace std;
struct Edge
{
	int MFrom;
	int MTo;
};

void solve()
{
	int n, m;
	while(cin >> n >> m, n || m)
	{
		vector< vector<int> > Vertex(n);
		vector<Edge> Vec(m);
		for(int i = 0; i < m; ++i)
		{
			cin >> Vec[i].MFrom >> Vec[i].MTo;
			Vec[i].MFrom--; Vec[i].MTo--;
		}
		for(int i = 0; i < m; ++i)
		{
			Edge e = Vec[i];
			Vertex[e.MFrom].push_back(e.MTo);
			Vertex[e.MTo].push_back(e.MFrom);
		}
		set<int> Set;
		for(int i = 0; i < Vertex[0].size(); ++i)
		{
			int To = Vertex[0][i];
			Set.insert(To);
			for(int j = 0; j < Vertex[To].size(); ++j)
			{
				Set.insert(Vertex[To][j]);
			}
		}
		Set.count(0) ? cout << Set.size() - 1 : cout << Set.size();
		cout << endl;
	}
}

int main()
{
	solve();
	return(0);
}