Counting sheep is a mental discipline used as a way of putting oneself to sleep.
What you’re supposed to do is imagine an endless series of identical white sheep jumping over a fence, and count them as they go. Presumably, occupying the mind with something simple, repetitive, and rhythmic will be so boring that you fall asleep.
An early reference to counting sheep as a means of attaining sleep can be found in Illustrations of Political Economy by Harriet Martineau, from 1832: “It was a sight of monotony to behold one sheep after another follow the adventurous one, each in turn placing its fore-feet on the breach in the fence, bringing up its hind legs after it, looking around for an instant from the summit, and then making the plunge into the dry ditch, tufted with locks of wool. The recollection of the scene of transit served to send the landowner to sleep more than once.”
An even earlier reference can be found in Don Quixote by Miguel de Cervantes, from 1605 (though Cervantes substituted “goats” for “sheep”). Cervantes probably adapted the story of counting goats from a story of counting sheep in the early twelfth-century Spanish work Disciplina Clericalis, where the idea of counting sheep is humorous. Disciplina Clericalis draws mainly on literary sources from the Islamic world.
Although the practice is rarely used as a solution for insomnia, it has been so commonly represented in cartoons, comic strips, and other mass media, that it is deeply ingrained in popular culture. The term “counting sheep” is now an idiom for insomnia.
An experiment conducted by researchers at Oxford University, not involving visualization of sheep, found that subjects who imagined “a beach or a waterfall” were forced to expend more mental energy, and fell asleep faster, than those asked to “simply distract from thoughts, worries and concerns.” Sleep could be achieved by any number of complex activities that expend mental energy.
There are many references to counting sheep in contemporary culture, including Philip K. Dick’s science fiction novel, Do Androids Dream of Electric Sheep?
Freshly roasted rack of lamb, with mint sauce, might work better for me.