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

#define for_(i,a,b) for(int i=(a);i<(b);++i)

int main() {
	int n, m;
	
	while (cin >> n >> m, n) {
		vector< vector< int > > mat(n, vector< int >(n, 0));
		
		for_(i,0,m) {
			int a, b;
			cin >> a >> b;
			--a; --b;
			mat[a][b] = mat[b][a] = 1;
		}
		
		vector< int > ans(n, 0);
		
		for_(i,0,n) {
			if (mat[0][i]) {
				ans[i] = 1;
				for_(j,0,n) if (mat[i][j]) ans[j] = 1;
			}
		}
		
		int c = accumulate(ans.begin(), ans.end(), int());
		cout << (c > 0 ? c - 1 : 0) << endl;
	}
}