Q. Can one count in one’s mind the ten people needed for a minyan?

A. It is prohibited to directly count Jewish people, even for the purpose of doing a mitzva (Yuma 22b – Rambam, Temidim 4,4).

Horav Shlomo Miller’s Shlit”a opinion is that counting in one’s mind is not considered an act, and is therefore not included in the above prohibition.

Ein Eliyahu (Pesachim 64b) elucidates why King Agripas was advised by the Cohen Gadol, to count the people by tallying the kidneys of all offered Pesach sacrifices. He explains; that the kidneys represent intellect and advise (Chulin 11a), and as mentioned above, are not included in this prohibition.

Rabbi A. Bartfeld as revised by Horav Shlomo Miller Shlit”a