#include <iostream>
#include <vector>
#include <algorithm>
#include <stack>
#include <string>
#include <map>
#include <functional>
#include <cmath>
#include <cstdio>
using namespace std;

int n, m;
int a[10000];
int b[10000];

int main(){
  while(cin >> n >> m, n || m){
    bool I[500][500] = {}, ans[500] = {};
    int cnt = 0;
    for(int i = 0; i < m; i++){
      cin >> a[i] >> b[i];
      a[i]--;b[i]--;
      I[a[i]][b[i]] = true;
      I[b[i]][a[i]] = true;
    }
    for(int i = 1; i < n; i++){
      if(I[0][i] == true){
        ans[i] = true;
        for(int j = 1; j < n; j++){
          if(I[i][j]){
            ans[j] = true;
          }
        }
      }
    }
    for(int i = 0; i < n; i++){
      if(ans[i])cnt++;
    }
    cout << cnt << endl;
  }
}