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



int main(void)
{
	int N,M,a,b;

	while(cin >> N >> M, N | M){
		bool stu1[1000] = {}, stu2[1000] = {};
		vector<int> vec[1000];
		for(int i = 0; i < M; i++){
			cin >> a >> b;

			vec[a].push_back(b);
			vec[b].push_back(a);
		}

		for(int i = 0; i < vec[1].size(); i++){
			stu1[vec[1][i]] = true;
		}

		for(int i = 1; i <= N; i++){
			if(stu1[i]){
				for(int j = 0; j < vec[i].size(); j++)
					stu2[vec[i][j]] = true;
			}
		}

		stu1[1] = stu2[1] = 0;

		int ans = 0;
		for(int i = 1; i <= N; i++)
			if(stu1[i] | stu2[i])
				ans++;
		
		cout << ans << endl;
	}
	return 0;
}