#include <iostream>
#include <set>

using namespace std;

#define rep(i,a,b) for(int i=(a); i<(b); i++)

int main(){
  int m,n;
  while(cin >> n >> m, m + n){
    int p[10001][2];
    set<int> fri1;
    set<int> fri2;
    rep(i,0,m){
      int a,b; cin >> a >> b;
      p[i][0] = a;
      p[i][1] = b;
      if(a == 1 || b == 1){
        fri1.insert(a);
        fri1.insert(b);
      }
    }
    if(fri1.size() == 0){
      cout << 0 << endl;
      continue;
    }
    rep(i,0,m){
      if(fri1.find(p[i][0]) != fri1.end() || fri1.find(p[i][1]) != fri1.end()){
        fri2.insert(p[i][0]);
        fri2.insert(p[i][1]);
      }
    }
    cout << fri2.size()-1 << endl;
  }
  return 0;
}
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,m,a,b,x=0,count=0;
  while(1){
    cin >> n;
    if(n == 0) break;
    cin >> m;
    int data[n][n];
    int str[501]={0};
    for(int i=0;i<n;i++){
      for(int j=0;j<n;j++){
	data[i][j]=0;
      }
    }
    for(int i=0;i<m;i++){
      cin >> a >> b;
      data[a-1][b-1]++;
      data[b-1][a-1]++;
      if( a == 1 ){
	str[x]=b-1;
	x++;
      } else if( b == 1){
	str[x]=a-1;
	x++;
      }
    }
    for(int i=0;i<x;i++){
      for(int j=1;j<n;j++){
	if(data[str[i]][j] != 0 && data[0][j] == 0){
	  data[0][j]++;
	}
      }
    }
    for(int i=1;i<n;i++){
      if( data[0][i] != 0){
      	count++;
      }
    }
    cout << count << endl;
    count=0;
    x=0;
  }
  return 0;
}