How to include post count in this “get_tags” snippet

where exactly?
example below is for the count getting shown in brackets after the tag name, outside the link:

<?php 
$tags = get_tags();    
  if ($tags) {    
  foreach ($tags as $tag) {    
    echo '<li><a href="' . get_tag_link( $tag->term_id ) . '" title="' . sprintf( __( "View all posts in %s" ), $tag->name ) . '" ' . '>' . $tag->name.'</a> ('.$tag->count.') </li> ';    
  } 
  };
?> 

http://codex.wordpress.org/Function_Reference/get_tags

error code: 523