Frequency counting