// AOJ 0545
#include<cstdio>
#include<cstring>
#include<vector>
#define rep(i,a) for( int i = 0; i != (a); ++i )
#define repi(i,a,b) for( int i = (a); i != (b); ++i )

int n, m;
std::vector<int> G[500];
bool used[500];

void dfs( int d, int v )
{
	used[v] = true;

	if( !d )
		return;

	rep( i, G[v].size() )
		dfs( d-1, G[v][i] );
	
	return;
}

int main()
{
	while( scanf( "%d%d", &n, &m ), n|m )
	{
		memset( used, false, sizeof( used ) );
		rep( i, 500 )
			G[i].clear();

		rep( i, m )
		{
			int a, b;
			scanf( "%d%d", &a, &b );
			--a; --b;
			G[a].push_back( b );
			G[b].push_back( a );
		}

		dfs( 2, 0 );

		int ans = 0;
		repi( i, 1, n )
			ans += used[i];

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

	return 0;
}