Implements count command.