
#include <iostream>
using namespace std;
int dict[500];
int f[500][500];
int n, m;
void solve(int a, int depth)
{
    if (depth == 3) return;
    dict[a] = 1;
    for(int i = 0; i < n; ++i) if (f[a][i] == 1) solve(i, depth + 1);
}
int main(void)
{
    while (cin >> n >> m, n && m) {
        dict[0] = 1;
        for(int i = 0; i < m; ++i) {
            int a, b; cin >> a >> b;
            a--; b--;
            f[a][b] = f[b][a] = 1;
        }
        solve(0, 0);
        int ans = 0;
        for(int i = 1; i < n; ++i) {
            if (dict[i]) ans++;
        }
        cout << ans << endl;
        for(int i = 0; i < 500; ++i) {
            dict[i] = 0;
            for(int j = 0; j < 500; ++j) f[i][j] = 0;
        }
    }
}