#include <iostream>
#include <queue>
#include <vector>
using namespace std;

int main() {
  int n, m;
  while (cin >> n >> m, n | m) {
    vector<vector<int>> graph(n);
    for (int i = 0; i < m; ++i) {
      int a, b; cin >> a >> b; --a; --b;
      graph[a].push_back(b);
      graph[b].push_back(a);
    }
    vector<int> dist(n, 3);
    queue<int> Q;
    Q.push(0);
    dist[0] = 0;
    while (!Q.empty()) {
      int v = Q.front(); Q.pop();
      for (int w : graph[v]) {
        if (dist[w] == 3) {
          dist[w] = dist[v] + 1;
          Q.push({w});
        }
      }
    }
    int ans = 0;
    for (int d : dist)
      if (d < 3) ++ans;
    cout << ans - 1 << endl;
  }
}
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
  while(1){
  int n,i,a[10000],b[10000],c=0,m,j,d[1000000]={0},y=1,e=1,g=0,w=0;
    cin >> n >> m;
    if(n==0 && m==0){
      break;
    }
    for(i=1;i<=m;i++){
      cin >> a[i] >> b[i];
    }
    for(i=1;i<=m;i++){
      if(a[i]==1){
	d[y]=b[i];
	y++;
      }
      else if(b[i]==1){
	d[y]=a[i];
	y++;
      }
    }
    w=y;
    for(i=1;i<w;i++){
      for(j=1;j<=m;j++){
	if(d[i]==a[j] && b[j]!=1){
	  d[y]=b[j];
	  y++;
	}
	if(d[i]==b[j] && a[j]!=1){
	  d[y]=a[j];
	  y++;
	}
      }
    }
    sort(d,d+y);
    for(i=1;i<y;i++){
      if(c!=d[i]){
	g++;
      }
      c=d[i];
    }

    cout << g << endl;
  }
}