Implement element counting