Counting sheep is a mental exercise used in some cultures as a means of putting oneself to sleep. In most depictions of the activity, the practitioner envisions an endless series of identical white sheepjumping over a fence, while counting them as they do so. – by Wikipedia
When counting sheep is running out of it’s power, this is what you should do:
You are still stressed out and wide awake at 3am? Try upping your daily intake of prebiotic-rich foods – like apples, asparagus, beans, and onions – which nourish friendly gut bacteria (a.k.a. probiotics). UC Boulder scientists reported that when good bacteria are well-fed, they do their jobs better. One of these jobs? Calming the anxiety that keeps you up.
Source: Dr Ox the Good Life