How to limit total number of posts in wp query loop?

You can use the found_posts filter to alter the number of posts WordPress reports finding from a query.

add_filter( 'found_posts', 'wpd_found_posts', 10, 2 );
function wpd_found_posts( $found_posts, $query ) {
    if ( $query->is_home() && $query->is_main_query() ) {
        return 25;
    }
}