Frequency Counter Code