ONE MAY NOT COUNT JEWS [Ayin Hara:counting people]
Gemara
Beraisa: The appointee told them 'stick out your fingers to be counted'.
This supports R. Yitzchak, who forbids to count Yisraelim even for a Mitzvah:
We learn from "Va'Yifkedem b'Vazek" (the Yisraelim who came to save Yavesh Gil'ad from Nachash ha'Amoni stuck up shards, and they counted the shards).
Objection (Rav Ashi): Perhaps 'Vazek' does not mean shard, rather, it is the name of the city where they counted them - "Va'Yimtze'u Es Adoni Vezek"!
Rather, we learn from "Va'Yifkedem ba'Tela'im" (they counted Yisrael via sheep).
R. Elazar: One who counts Yisrael transgresses an Aseh - "V'Hayah Mispar Benei Yisrael k'Chol ha'Yam Asher Lo Yimad v'Lo Yisafer".
Rav Nachman bar Yitzchak: He transgresses two Lavim - Lo Yimad and Lo Yisafer.
Contradiction: It says "V'Hayah Mispar Benei Yisrael k'Chol ha'Yam", and it says "Asher Lo Yimad v'Lo Yisafer"!
Answer #1 (R. Yonason): Yisrael can be counted only when they are not doing Hash-m's will.
Answer #2 (Rebbi): They can be counted by Hash-m, but not by people.
Berachos 62b - R. Elazar: "Im Hash-m Hesischa Vi" - Hash-m said to David, you say I enticed Shaul to pursue you?! I will cause you to stumble in a matter that even children know!
"Ki Sisa... v'Nosnu Ish Kofer Nafsho" (Benei Yisrael may not be counted directly, only indirectly, e.g. through Shekalim).
"Va'Ya'amod Satan Al Yisrael va'Yases Es David... Lech Meneh Es Yisrael" - David counted Yisrael but did not use Shekalim for atonement. A plague began.
Rishonim
Rambam (Hilchos Temidim u'Musafim 4:4): We count their fingers because one may count Yisraelim only through something else - "Va'Yifkedem ba'Tela'im".
Question (Talmidei R. Efrayim): Counting fingers is like counting the people!
Answer (Teshuvas ha'Rambam, brought in Frankel Rambam): The Gemara (23a) concludes that a Kohen who stuck out two fingers is counted like two, unless one of them was a thumb. Therefore, we are not counting the Kohanim, rather, the fingers.
Ramban (Shmos 30:12): The Torah did not explicitly say that the Mitzvah to count Benei Yisrael through Shekalim is for all generations, therefore David erred and counted Yisrael directly. A plague resulted, and David confessed his sin.
Question: Why does the Gemara learn the Isur from Nevi'im, and not from the Torah ("Ki Sis... v'Nosnu Ish Kofer Nafsho")?
Answer #1 (Maharsha Yoma 22b DH Asur): One might have thought that then a Kaparah was needed for the Egel. Therefore we learn from Sha'ul's count, when no Kaparah was needed. Also, the count was done with Sha'ul's sheep; Kaparah must come from the sinner's own money.
Objection (Iyun Yakov DH Asur): The Gemara (Berachos 62b) calls this something that even children know ("Ki Sisa...", i.e. it is explicit in the Torah)!
Answer #2 (Iyun Yakov): Rashi explains that "Ki Sisa..." teaches that when you want to count Yisrael, you must use Shekalim. It does not teach about counting for a Mitzvah. This we learn from Sha'ul.
Ramban (Bamidbar 1:3): Surely, David was careful to count Benei Yisrael through Shekalim to avoid a plague. Yo'av tried to dissuade David; surely, he would not count Yisrael directly! David was punished because there was no need for the census; he merely wanted to rejoice over being king over many subjects. Alternatively, even through Shekalim the Torah permits to count only men above 20, and David counted from 13 and above. However, the Medrash (Berachos 62b) says that he counted without Shekalim.
R. Chananel: One who counts Yisrael transgresses two Lavin, Lo Yimad and Lo Yisafer. This is when Yisrael are doing Hash-m's will. When they are not, "V'Hayah Mispar...", they are countable. Rebbi says, they can be counted by Hash-m, but not by people.
Einayim l'Mishpat (Berachos 62b DH v'Nosnu): Perhaps (most) Poskim do not bring the Isur to count Yisrael because they hold like R. Chananel. It is permitted nowadays, for Yisrael are not doing Hash-m's will, like it says in Bava Basra (10a. Turnusrufus said that Yisrael are not doing Hash-m's will, and R. Akiva did not dispute this.)
Rebuttal (Tzitz Eliezer 7:3): R. Chananel does not mean that it is Asur to count Yisrael only when they are doing Hash-m's will. Rather, at such a time they merit that it is impossible to count them all. Also, nowadays we cannot know whether or not Hash-m considers that we are doing His will.
Poskim
Magen Avraham (OC 156:2): One may not count Yisraelim, even to make a lottery without intent to know their number, even for a Mitzvah, unless he counts only fingers.
Kaf ha'Chayim (156:14): If there is no need to know the number of Yisrael, they may be counted through Shekalim, but not through shards.
Kaf ha'Chayim (55 11, citing Pele Yo'etz (Moneh)): Some think that one may count Yisrael via Aleph, Beis,... as long as he does not mention numbers. This is wrong. One may count mentally if he does not say the numbers.
Kitzur Shulchan Aruch (15:3): To determine whether or not there is a Minyan, the custom is to say one word of "Hoshi'a Es Amecha..." corresponding to each person.
Shmiras ha'Guf veha'Nefesh 242 (1): Pe'as ha'Shulchan permits counting fingers for the sake of a Mitzvah. Chasam Sofer permits this only if it does not give the number of Yisraelim (e.g. a lottery).
Karyana d'Igrata (244): One may not count Yisraelim even if the count is not exact.