The $wp_query->current_post inside the wordpress will help you to fix this issues. It will get the count of the current loop executed in the wordpress. And if the loop (post) is the 4th one , we can block the script from being run.
current_post < 3) : ?>Advertisements
Remember that the wordpress loop count start with zero, you can limit the number of ad units displayed to 1 or 2 by changing the $wp_query->current_post < 3 as per you wish