count_records function

Count the number of records