#include <iostream>
#include <vector>
using namespace std;

typedef vector <bool> VB;
typedef vector <VB> VVB;

int main( void )
{
	int n, m;
	while ( cin >> n >> m && n && m )
	{
		VVB G( n+1, VB( n+1, false ) );
		for ( int i = 0; i < m; i++ )
		{
			int a, b; // a-bツづ債友ツ達
			cin >> a >> b;
			G[a][b] = G[b][a] = true;
		}

		VB F( n+1, false );
		for ( int i = 0; i <= n; i++ )
		{
			if ( G[1][i] )
			{
				F[i] = true;
			}
		}

		VB R( n+1, false );
		for ( int i = 0; i <= n; i++ )
		{
			if ( F[i] == false ) continue;
			for ( int j = 0; j <= n; j++ )
			{
				if ( j == 1 ) continue;
				if ( G[i][j] )
				{
					R[j] = true;
				}
			}
		}

		int answer = 0;
		for ( int i = 0; i <= n; i++ )
		{
			if ( F[i] || R[i] )
			{
				answer++;
			}
		}

		cout << answer << endl;

	}
	return 0;
}
#include<iostream>
#include<algorithm>

using namespace std;

int main()
{
	int friends[500];
	int n,m;
	pair<int, int> student[10000];
	int result[100];
	int I = 0;
	for (int i = 0;; i++)
	{
		cin >> n;
		cin >> m;
		if (m == 0 && n == 0)
		{
			break;
		}

		for (int a = 0; a < 500; a++)
		{
			friends[a] = 0;
			student[a].first = 0;
			student[a].second = 0;
		}

		for (int a = 0; a < m; a++)
		{
			cin >> student[a].first >> student[a].second;
			student[a].first--;
			student[a].second--;
		}

		sort(student, student + m);

		friends[0] = 1;

		for (int a = 0; a < m; a++)
		{
			if (student[a].first == 0)
			{
				for (int b = 0; b < m; b++)
				{
					if (student[b].first == student[a].second)
					{
						friends[student[b].second] = 1;
					}
					if (student[b].second == student[a].second)
					{
						friends[student[b].first] = 1;
					}
				}
				friends[student[a].second] = 1;
			}
		}

		result[i] = -1;
		for (int a = 0; a < n; a++)
		{
			if (friends[a] == 1)
			{
				result[i]++;
			}
		}
		I++;
	}

	for (int a = 0; a < I;a++)
	{
		cout << result[a] << endl;
	}

	return 0;
}