The Shulhan Aruch (Orah Haim 99:1) rules that if a person has become inebriated such that he cannot articulate his words properly, and is not fit to appear before a king, then he may not pray, and if he does pray in such a condition, his prayer is considered an "abomination." The Ben Ish Hai (Rav Yosef Haim of Baghdad, 1833-1909) cites the Bet Yehuda (Rav Yehuda Ayash, Algeria, 1700-1759) as ruling that a person in this state cannot be counted toward a Minyan. Interestingly, the Ben Ish Hai adds that since people in such a condition do not necessarily appear drunk, it is important to ensure that the ten men who comprise a Minyan are in fact sober and worthy of being counted. Hacham Ovadia Yosef, however, noted that this is not, in fact, what the Bet Yehuda wrote. The Bet Yehuda wrote that a person cannot be counted toward a Minyan if he had reached the point of "Shichruto Shel Lot" – the level of intoxication reached by Lot, who was so inebriated that he had intimate relations with his daughters, as he did not recognize them. It is only if a person is drunk to this extent, that he is entirely unaware of what is happening and is not thinking straight at all, that he may not be counted toward a Minyan. Such a person is exempt from Misvot due to his temporary state of mental impairment, and so he cannot be counted toward a Minyan. If, however, a person is merely tipsy, then although he should not pray, he may nevertheless be counted toward a Minyan. Hacham Ovadia noted that even somebody who is asleep can be counted toward a Minyan, so certainly somebody who is drunk can be counted, as long as he has not reached the point of "Shichruto Shel Lot." Apparently, Hacham Ovadia writes, the Ben Ish Hai saw a faulty edition of the Bet Yehuda which mistakenly stated that even mild inebriation disqualifies a person from being counted. Hacham Ovadia noted that a number of other Poskim also cited the Bet Yehuda as disqualifying even a mildly inebriated person, as they, too, evidently used the faulty edition of this work. The Mishna Berura writes that if necessary, a mentally challenged individual may be counted toward a Minyan if he has enough understanding to pray properly and recognize that he prays to Hashem. If there is no other option, then such a person may be counted. Rav Yisrael Bitan writes that this would apply also to a mildly inebriated individual, who may be counted toward a Minyan when necessary. This situation often arises on Purim, when people drink and become inebriated. Summary: A person who is so drunk that he is entirely unaware of what he is doing may not be counted toward a Minyan. If a person is tipsy and cannot enunciate his words properly, then he should not pray, but he may be counted toward a Minyan, especially if he is needed for forming the Minyan.