//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
#include <complex>
using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<long, long> PLL;
typedef long long LL;
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

const double EPS = 1e-12;
const double INF = 1e12;


int main(){
	int N,M;
	while(cin>>N>>M){
		int d[501][501];
		REP(i,501)REP(j,501)d[i][j]=1000000;
		if(N==0&&M==0)break;
		REP(i,M){
			int a,b;
			cin>>a>>b;
			a--;b--;
			d[a][b]=1;d[b][a]=1;
		}
		REP(k,N){
			REP(i,N){
				REP(j,N)d[i][j]=min(d[i][j],d[i][k]+d[k][j]);
			}
		}
		int res=0;
		FOR(i,1,N)if(d[0][i]<=2)res++;
		cout<<res<<endl;
	}
	return 0;
}
#include <iostream>
#include <queue>

using namespace std;



int main(){
	
	
	while(1){
		queue<int> Q;
		int n,m,a[10000][2],b,i,j,k;
		bool c[500]={};
		cin >> n >> m;
		if(n==0&&m==0){
			return 0;
		}
		for(j=0, i=0;i<m;i++){
			cin >> a[i][0] >> a[i][1];
			if(a[i][0]==1){
				c[a[i][1]-1]=true;
				Q.push(a[i][1]);
			}else if(a[i][1]==1){
				c[a[i][0]-1]=true;
				Q.push(a[i][0]);
			}
		}
		for(;Q.size()!=0;){
			b=Q.front();
			Q.pop();
			for(j=0;j<m;j++){
				if(b==a[j][0]){
					c[a[j][1]-1]=true;
				}
				if(b==a[j][1]){
					c[a[j][0]-1]=true;
				}
			}
		}
		int count=0;
		for(i=0;i<500;i++){
			if(c[i]==true){
				count++;
			}
		}
		cout << count-1 << "\n";
	}
}
	