#include <bits/stdc++.h>
using namespace std;
int n,m,ans,li[505][505],h[10005],a,b;
int main(){
    while(1){
    cin >> n >>m;
    if(n==0&&m==0)break;

    for(int i=0;i<m;i++){
        cin >> a >> b;
        li[a][b]=1;
    }

    for(int i=2;i<=n;i++){
        if(li[1][i]==1||li[i][1]==1){
            if(h[i]==0){
                h[i]=1;
                ans++;
            }
                for(int j=2;j<=n;j++){
        if(li[j][i]==1||li[i][j]==1){
            if(h[j]==0){
                h[j]=1;
                ans++;
            }
        }
    }

        }
    }

    cout << ans << endl;
    for(int i=0;i<=n;i++)h[i]=0;
    std::fill(li[0],li[504],0);
    ans=0;
    }

return 0;
}
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <numeric>
#include <algorithm>
#include <bitset>
#include <complex>
#include <fstream>
using namespace std;
typedef vector<int> vint;
typedef pair<int,int> pint;
#define rep(i,n) for(int i = 0; i < n; i++)
#define MSG(a) cout << #a << " " << a << endl;
template<class T, class C> pair<T,C> mp(T a, C b){ return make_pair(a, b);}

int main()
{
	int n;
	while(cin >> n && n)
	{
		vector<vector<bool> > s(n, vector<bool>(n));
		rep(i,n+1) fill(s[0].begin(), s[0].end(), false);

		int m;
		cin >> m;

		rep(i,m)
		{
			int a, b;
			cin >> a >> b;
			s[a-1][b-1] = s[b-1][a-1] = true;
		}

		int res = 0;

		for(int i = 1; i < n; i++)
		{
			if(s[0][i])	res++;
			else
			{
				for(int j = 1; j < n; j++)
				{
					if(s[0][j] && s[j][i])
					{
						res++;
						break;
					}
				}
			}
		}
		cout << res << endl;
	}
}