#include <stdio.h>
#include <vector>

using namespace std;

vector<int> sei[100000];

bool s1[100000];
bool s2[100000];

int main(){
while(1){
int n,m;
scanf("%d%d",&n,&m);
if(n == 0){
return 0;
}
for(int i = 0; i < n; i++){
sei[i].resize(0);
}
for(int i = 0; i < m; i++){
int a,b;
scanf("%d%d",&a,&b);
a--;
b--;
sei[a].push_back(b);
sei[b].push_back(a);
}
for(int i = 0; i < n; i++){
s1[i] = false;
s2[i] = false;
}
for(auto i : sei[0]){
s1[i] = true;
}
for(int i = 0; i < n; i++){
if(s1[i]){
for(auto j : sei[i]){
s2[j] = true;
}
}
}
int all = 0;
for(int i = 0; i < n; i++){
if(s1[i] || s2[i]){
all++;
}
}
printf("%d\n",all - 1);
}
}