#include <iostream>
#include <set>

using namespace std;

int main() {
  int n, m, a, b;
  while (true) {
    set<int> friends[500];
    set<int> my_friends;
    cin >> n >> m;
    if (n == 0) {
      return 0;
    }
    for (int i = 0; i < m; ++i) {
      cin >> a >> b;
      friends[a - 1].insert(b - 1);
      friends[b - 1].insert(a - 1);
    }
    my_friends.insert(0);
    for (int i = 0; i < 2; ++i) {
      set<int> tmp;
      for (set<int>::iterator it = my_friends.begin(); it != my_friends.end(); ++it) {
        for (set<int>::iterator it2 = friends[*it].begin(); it2 != friends[*it].end(); ++it2) {
          tmp.insert(*it2);
        }
      }
      my_friends.insert(tmp.begin(), tmp.end());
    }
    cout << my_friends.size() - 1 << endl;
  }
}