40. (B) The count variable must be reset to 1 as soon as index is incremented in the outer while loop, so that when a new run of equal values is found, count starts out as 1.