Here is a link explaining the breath counting method, known as susokukan:
http://www.ningenzen.org/lay.html#a1.1.4
A quote pertinent here would be ;
"Now, you have sound visual and auditory senses and naturally you will see and hear things and sounds around you. Nevertheless the reaction of mind to them shall be "to see with no trace of seeing and to hear with no trace of hearing"; thus the mind keeps itself unfettered, despite the presence of things as is cast on mind. "