#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <utility>

using namespace std;

int main() {
	int n, m, a[10000], b[10000];
	while (cin >> n >> m && n != 0) {
		vector<bool> fri(n + 1);
		fri[1] = true;
		for (int i = 0; i < m; ++i) {
			cin >> a[i] >> b[i];
		}
		
		for (int i = 0; i < 2; ++i) {
			vector<bool> temp = fri;
			for (int j = 0; j < m; ++j) {
				if (fri[a[j]])
					temp[b[j]] = true;
				if (fri[b[j]])
					temp[a[j]] = true;
			}
			fri = temp;
		}

		int ans = 0;
		for (int i = 2; i <= n; ++i) {
			if (fri[i])
				ans++;
		}
		cout << ans << endl;
	}

	return 0;
}