Count the length of an iterator/generator