Count occurance of an integer i from 0 to N.