Counting Jewish People
There’s a prohibition to count Jewish people. For the background see #Background of the issue below.
- There’s a prohibition to count Jewish people.  According to most authorities this prohibition is a biblical command. 
- Counting Jewish people with Hebrew letters starting aleph, bet, gimmel and so on is forbidden. 
By means of something else
- Counting through something else like counting the fingers of people is only permitted for a serious need or need of a mitzvah. 
- Counting through something else for no purpose is forbidden even if not done in front of those being counted. 
For a mitzvah
- The prohibition applies even when counting for a mitzvah. 
- The minhag is to allow counting for a mitzvah using the פסוק of Hoshiyah Et Amecha…הושיעה את עמך וברך את נחלתך ורעם ונשאם עד העולם in order to count for a minyan. However, some say that it's only permitted if one only counts in one's head.
- Many poskim permit counting in one’s thought (by looking and counting in one’s head without making any motions) for a mitzvah or any need. 
- Numbering Jewish graves is prohibited, however it’s permissible to number each section assuming that there are a different number of graves in each section. 
- It’s a problem of counting Jewish people when people or children standing in a line each recite their number. 
- Counting Jewish names on a list is a dispute. 
- Some hold that participating in the Israeli consenus is permissible  while others forbid. 
- It's forbidden to count part of Bnei Yisrael just like it is to count all of Bnei Yisrael. 
- Just like there is a prohibition on the one counting there's also a prohibition on the one being counted.
Background of the issue
The first source which introduces the prohibition of counting Jewish people is from the פסוק in Ki Tisa כי תשא את ראש בני ישראל לפקדיהם ונתנו איש כפר נפשו ליהוה בפקד אתם ולא יהיה בהם נגף בפקד אתם: Rashi writes that the פסוק implies that the count incurs the Ayin Hara rather they should give half shekels in order to be counted and in this way they’ll be spared from a plague. According to this understanding of the פסוק there’s a general prohibition to count Jews directly and there’s also a danger of incurring a plague.
However, the Mishna Yoma 22b writes that when the officer in charge of appointing specific Cohanim to the jobs in that day’s service in the Bet HaMikdash, the officer would pick a high number, each cohen would put out one or two fingers and then the officer would count the fingers until he reached the number he picked. The Gemara explains that they didn’t count the heads of the Cohanim because it’s prohibited to count Jews even for the purpose of a mitzvah and proves it from a פסוק by Shaul HaMelech who counted the people for the army through sheep (he gave each person a sheep and then collected the sheep and counted them). Then the Gemara goes on to quote two other pesukim in Nach to prove the prohibition to count Jews.
[Some explain that the reason it was permitted to count fingers and not heads is because when counting heads one is certain to come to a precise total while when counting fingers one is uncertain whether one will actually know the number of Jews considering that some put out two fingers and some only one. On the other hand some said that counting any part of a person that’s not totally an essential part of the body (finger) is like not counting a Jew directly. (Sh”t Igrot Moshe Y”D 2:117(2).)]
The question asked is that why didn’t the Gemara quote the פסוק in Ki Tisa which would be a biblical source instead of quoting from Neviyim. Some answer that it was possible to think that the reason the half shekelim were collected was in collect to atone for the Chet HaEgel really counting directly was permitted, therefore the Gemara brings a source in Nach to prove the prohibition (Maharsha Yoma). Alternatively some answer that perhaps Moshe counted them directly and the coins were given to remove the Ayin Harah but there’s no proof to the actual prohibition and so the Gemara quoted the pesukim by shaul (Makom Shmuel). However, some answered that really there is a prohibition from the פסוק in Ki Tisa but the Gemara wanted to prove that it was prohibited even for mitzvah purposes and the count in Ki Tisa wasn’t for mitzvah purposes. The implication of this is that the count done by Moshe wasn’t for a mitzvah but nonetheless was permitted by means of counting something besides the actual people (Tzitz Eliezer 7:3:1, Divrei Emet). Yet, this last point is disputed and some rejected this leniency saying that if this were true then why didn’t Yoav (David’s general who carried out the count) collect something from each Jew and then count that, rather it must be that there’s no leniency to count by means of something else except for the purposes of a mitzvah (Bear Sheva).
Nonetheless, there is an explicit Gemara Brachot 62 which says that after David sinned, Hashem said that he would make David falter even on something so simple every schoolchild would know and so it happened that David counted the Jews and there was a plague. Interestingly that Gemara quotes the פסוק in Ki Tisa and comments that it was something that everyone knew, seemingly implying that it’s a bona fide prohibition. Based on this understanding of the פסוק in Ki Tisa there’s a question as to why the Rishonim who listed all 613 מצות didn’t count this one. Some drew from this that actually the entire prohibition was Derabbanan (Rashbetz) while others answered that it wasn’t counted because it wasn’t explicit in the Torah and it’s only a negative command implied from a positive one which isn’t usually counted amongst the 613 (Divrei Emet).
There are numerous discussions on this halachic topic drawing on all different types of sources and logic. This discussion has reemerged at two other points in history. When European countries began to take public censuses, it was discussed at length with the חתם סופר ruling strictly that one shouldn’t participate while the Peot HaShulchan concluding leniently. And more recently, there has been a tremendous discussion every time the Israeli census takes place, some of the Gedolim permitting while others advising people from refraining.
- The source in Torah for the prohibition is found in Shemot 30:12 which says that each person counted must give an atonement in order to prevent a plague. Gemara Brachot 62b relates that when David HaMelech made a mistake to count the Jews a plague actually did affect the people. Gemara Yoma 22b rules that it's forbidden to count Jews even for a mitzvah purpose based on Shmuel 1, 15:4 which says that Shaul counted the people by means of lambs, giving one to each person and then collecting them again. Most achronim (Magen Avraham 156:2, Pri Chadash 55:1, Kaf HaChaim 13:10, Shulchan Aruch HaRav 156:15) hold that the prohibition still applies nowadays and are supported by the Rambam Temidin UMussafin 4:4. The Aynayim LeMishpat (Brachot 62b) says that there’s no prohibition nowadays based on Rabbenu Chananel in Brachot; however, the Sh”t Tzitz Eliezer 7:3 (Chapter 1 section 2) strongly disagrees with that explanation of the Gemara. All achronim agree that there’s still a prohibition in effect nowadays including the Magen Avraham 156:2, Gra (Aderet Eliyahu Parshat Ki Tisa).
- Tzitz Eliezer 7:3(8:1) and Shevet HaLevi 1:34 write that there's a biblical prohibition to count Jews. However, Magen Giborim (Elef LeMagen 55:21) writes that there's no lo taaseh (biblical) but nonetheless it is forbidden.
- The Kaf HaChaim 55:11, Rav Mordechai Eliyahu in his comments to Kitzur S”A 15:3, and Yalkut Yosef 55:2 write clearly that counting aleph, bet, gimmel is forbidden.
- Sh”t Tzitz Eliezer 7:3(8:3), Seridei Esh 1:140. See also Sh”t Shevet HaLevi 1:34 and Chatom Sofer 7.
- Sh”t Tzitz Eliezer 7:3(8:4)
- Gemara Yoma 22b, Rambam Pirush Mishnayot Yoma 22b, Magen Avraham 156:2, Tzitz Eliezer 7:3(8:2)
- Kitzur Shulchan Aruch 15:3 writes that Minhag Yisrael to count for a mitzvah purpose using the pasuk of Hoshiyah Et Amecha. Kesot HaShulchan 15:8 quotes the Kitzur S”A. Piskei Teshuvot 156:24 adds that it's also acceptable to use the pasuk VeAni BeRov Chasdecha quoting the Sefer HaOrah LeRashi vol 1 siman 56. Rav Mordechai Eliyahu's comments on Kitzur Shulchan Aruch 15:3 writes that even using this pasuk one shouldn't point but count in one's head. Yalkut Yosef (Pesukei DeZimrah 55:2) holds that it's permitted for a mitzvah if one either counts in one's head or if one counts using the pasuk of Hoshiya. Revivot Efraim 4:44(132) quotes an achron who has a safek about this issue. Minchat Asher Parshat Bamidbar (Siman 1:4) tries to explain the Kitzur Shulchan Aruch saying that perhaps when using the pasuk it's not considered counting since one doesn't know which word in the pasuk corresponds to which number other than that the whole pasuk is 10 words. [He prefers this explanation over saying that there's some segulah unique to this pasuk that protects those counted thereby permitting it. Regarding whether this pasuk is unique, see Podeh Et Avraham (Mem #19) who writes that one may use pasuk of VeShinantem and Lekat Kemach HaChadash 55:8 who writes that counting with bracha of Hamotzei is incorrect.] Sh"t Divrei Zev 10:13 writes that it's permitted to count Jews for a minyan. However, Yalkut Yosef (Pesukei DeZimrah, pg 351) argues based on the Sefer Itim (pg 352) who says it is a problem. See Yabia Omer YD 2:16(9). [See Orchot Rabbenu vol 3 pg 89, Or Torah 5766 Elul 136. Shelat Rav pg 167.]
- Yalkut Yosef (Piskei DeZimrah 55 note 2, Sherit Yosef vol 2 pg 93) permits counting for a minyan in one’s mind. Sh"t Tzitz Eliezer 7:3:(7:39), Minchat Asher (Bamidbar 1) in name of the Kaf HaChaim Sofer and Kaf HaChaim Palagi permit. However, Etz Yosef (Yoma 22b; quoted by Piskei Teshuvot 156:24) is strict.
- Sh”t Igrot Moshe Y”D 2:117(2)
- Shevet HaLevi 1:34
- Chatan Sofer (Y”D 106) in name of his father the חתם סופר who says that it’s forbidden Deoritta.
- Sh”t Shevet HaLevi O”C 9:35, Sh”t Mishpatei Uziel 4:2, Sh"t Seridei Esh 2:48, Menachem Kasher (Sh"t Divrei Menachem 1:36), Rabbi Unterman quoted in Techumin (vol 4 pg 335)
- Rabbi Goren (HaTzofeh Sivan 5743), Rav Chaim Kanievsky (HaTzofeh vol 15 pg 8 col 1; Nachal Eitan 6:10(7)), Sh"t Tzitz Eliezer 7:3, and the Edah Charedit (HaEdah Behalotcha 5733). For further discussion of census see Shevet Halevi 6:20, 9:35, Teshuvot VeHanhagot 3:387, Tzitz Eliezer 7:3.
- Tzitz Eliezer 7:3(8:5)
- Tzitz Eliezer 7:3(8:11)