#include <iostream>

using namespace std;

int main()
{
	int n, m;
	
	while (cin >> n >> m, n, m){
		bool num[510][510] = {false};
		int a, b;
		
		for (int i = 0; i < m; i++){
			cin >> a >> b;
			num[a][b] = true;
			num[b][a] = true;
		}
		
		bool member[510] = {false};
		for (int i = 2; i <= n; i++){
			if (num[1][i]){
				member[i] = true;
				for (int j = 2; j <= n; j++){
					if (num[i][j])  member[j] = true;
				}
			}
		}
		
		int count = 0;
		for (int i = 2; i <= n; i++){
			if (member[i])  count++;
		}
		cout << count << endl;
	}
}