calculate length of a list