import std.stdio,std.string,std.conv,std.algorithm,std.array;
 
void main()
{
    bool[501][501] M;
    while(true)
    {
        int n, m;
        string line=readln.chomp;
        try{n=line.to!int;}catch(Exception e){ throw new Exception(line);}
        try{m=readln.chomp.to!int;}catch(Exception e){ throw new Exception("m");}
 
        if(n==0&&m==0)break;
 
        foreach(unused;0..m)
        {
            int[] input;
            try{input=readln.split.map!(to!int).array;}catch(Exception e){ throw new Exception("list");}
            M[input[0]][input[1]]=true;
            M[input[1]][input[0]]=true;
        }
 
        int[int] num;
 
        foreach(i; 1..n+1)
        {
            if(M[1][i])
            {
                num[i]=0;
 
                foreach(j; 2..n+1)
                {
                    if(M[i][j])
                    {
                        num[j]=0;
                    }
                }
            }
        }
 
        writeln(num.length);
 
        foreach(i; 1..n+1) foreach(j; 1..n+1) M[i][j]=false;
    }
}