Breathing is both an involuntary and a voluntary process. You can alter the speed and the depth of your breathing, and you can choose to breathe through your mouth or your nose. These choices lead to physical changes in your body.
Slow, deep and steady breathing activates your parasympathetic response while rapid, shallow breathing activates your sympathetic response, involved in releasing cortisol and other stress hormones.
The combination of controlled breathing with counting can be particularly effective when your mind refuses to shut down at night, as it gives your mind something to focus on.
One breathing exercise involving counting that you could try is the 4-7-8 breathing technique taught by Dr. Andrew Weil. It’s a potent remedy for anxiety, as it acts as a natural tranquilizer for your nervous system.1Sleep — Why You Need It and 50 Ways to Improve It