move ec_count_of in utils.h