Implemented counting.