#include <bits/stdc++.h>

using namespace std;

#define MAX 500
#define MAX_M 10000

int main(){
  int N,M;
  while(cin >> N >> M,(N | M)){
    bool F[MAX] = {0},C[MAX] = {0};
    int A[MAX_M],B[MAX_M], idx = 0;
    for(int i = 0 ; i < M ; i++){
      int a,b;
      cin >> a >> b; a--; b--;
      if(!a){
        F[b] = C[b] = true;
      }else{
        A[idx] = a; B[idx++] = b;
      }
    }
    for(int i = 0 ; i < idx ; i++){
      if(!F[A[i]] && F[B[i]]){
        C[A[i]] = true;
      }else if(F[A[i]] && !F[B[i]]){
        C[B[i]] = true;
      }
    }
    cout << count(C,C+N,true) << endl;
  }
  return 0;
}