algo2: counting ones in cycle