Counting segment lenghts.