#include<iostream>
#include<set>
#include<algorithm>
using namespace std;
int main() {
	int n, m;
	bool a[500][500];
	while (cin >> n&&n!=0) {
		cin >> m;
		for (int i = 0; i < n; i++) fill(a[i], a[i] + n, false);
		set <int>d,f;
		for (int i = 0; i < m; i++) {
			int b,c;
			cin >> b >> c;
			if (b > c) swap(b, c);
			b--;
			c--;
			a[b][c] = true;
			a[c][b] = true;
			if (b == 0) {
				f.insert(c);
				d.insert(c);
			}
		}
		set<int>::iterator it = f.begin();
		while (it != f.end()) {
			for (int i = 1; i < n; i++) {
				if (a[(*it)][i]) {
					d.insert(i);
				}
			}
			it++;
		}
		cout << d.size() << endl;
	}
}