Implementing count method.