Changing post count on home page in WordPress template

Some professional WordPress websites usually have custom post roll layout and different post count on homepage. So this means when you go to second page of post roll you should’t see repeating items as a consequence of another post count than set in ‘Blog pages show at most’ setting in Reading section of Settings in WP-admin.
Solving this problem is a simple code you need to add before wordpress loop in your index.php or home.php:
if ( is_home() ) {
$posts_home = 9; //Set custom post number to show on home
if( !is_paged() ){
query_posts("posts_per_page=$posts_home");
} else {
if ( get_query_var('paged') != 2 )
$offsetting = $posts_home + ( ( get_query_var('paged') - 2 ) * get_query_var('posts_per_page') );
else
$offsetting = $posts_home;
query_posts($query_string . "&offset=$offsetting");
}
}
Here $posts_home is a custom number of post count to show on homepage.
So where do you pit this code of yours in the index.php file? That info would have been helpful.