#include <functional>
#include <algorithm>
#include <iostream>
#include <numeric>
#include <iomanip>
#include <utility>
#include <cstdlib>
#include <sstream>
#include <bitset>
#include <vector>
#include <cstdio>
#include <ctime>
#include <queue>
#include <deque>
#include <cmath>
#include <stack>
#include <list>
#include <map>
#include <set>

using namespace std;

typedef vector<int> vi;
typedef pair<int,int> pii;
typedef long long ll;

#define dump(x)  cerr << #x << " = " << (x) << endl
#define rep(i,n) for(int i=0;i<(n);i++)
#define ALL(a)  (a).begin(),(a).end()
#define pb push_back
#define sz size()

const double EPS = 1e-10;
const int INF = 100000000;


int main(){
    int n,m;
    while(cin>>n>>m){
        if(n==0 && m==0)break;
        
        int data[600][600]={};
        rep(i,600){
            rep(j,600){
                if(i==j){
                    data[i][j]=0;
                }
                else{
                    data[i][j]=INF;
                }
            }
        }
        
        rep(i,m){
            int a,b;
            cin>>a>>b;
            a--;b--;
            data[a][b]=1;
            data[b][a]=1;
        }
        
        rep(k,n){
            rep(i,n){
                rep(j,n){
                    data[i][j]=min(data[i][j],data[i][k]+data[k][j]);
                }
            }
        }
        int c=0;
        for(int i=1;i<n;i++){
            if(data[0][i]<=2)
                c++;
        }
        cout<<c<<endl;
    }
    return 0;
    
}
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define fr first
#define sc second
typedef vector<int> Vi;
typedef pair<int,int> Pii;
typedef pair<int,Pii> Pip; 
const int INF = (1<<30);
const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};

int main(){

  int n, m;
  int a[10000], b[10000];
  while( cin >> n >> m, n + m ) {
    map<int, int> maps;
    set<int> all;
    
    for(int i=0; i<m; i++) {
      cin >> a[i] >> b[i];
      if( a[i] == 1 ) {
	maps[b[i]] = 1;
	all.insert(b[i]);
      }
    }
    
    for(int i=0; i<m; i++) {
      if( maps[a[i]] == 1 ) {
	all.insert(b[i]);
      }
      if( maps[b[i]] == 1 ) {
	if( a[i]!= 1 ) {
	  all.insert(a[i]);
	}
      }
    }
    
    cout << all.size() << endl;
  }
}