#include <bitset>
#include <iostream>

using namespace std;

int main() {
  for (;;) {
    int N, M;
    cin >> N >> M;
    if (!N && !M) return 0;
    bitset<500> friend_list[500], guests;
    for (int i = 0; i < M; i++) {
      int a, b;
      cin >> a >> b;
      a--; b--;
      friend_list[a][b] = 1;
      friend_list[b][a] = 1;
    }
    guests = friend_list[0];
    for (int i = 0; i < N; i++)
      if (friend_list[0][i])
        guests |= friend_list[i];
    guests[0] = 0;
    cout << guests.count() << endl;
  }
}