How to make adverts automatically display in middle of content only on longer posts

Hi. Does anyone know how to make an advert appear in the middle of content, but only when the post is a certain length? E.G. if a post is only 100 words long, there isn’t enough room for an advert, but there would be room if it’s 500 words, for example.

Any ideas? thanks!

http://php.net/manual/en/function.str-word-count.php

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

Retrieve the content of the post/page, and use the standard PHP function to count the words.

Then modify and echo the content as appropriate to display the content and your ad(s).

Thank you!