Until last week, the answer to this question would have been 34. Supreme Court Justice Antonin Scalia makes the 35th Justice to pass away while actively serving on the court, and only the second Justice to pass away while serving since the 1950s.
Supreme Court Justices are appointed by the President of the United States when a vacancy occurs on the nine person court. Justices do not have term limits, and therefore can continue in their placement until they pass away or choose to retire. Until the early 20th century, it was not uncommon for Justices to serve on the US Supreme Court until they died. However, sometime in the mid-1950s, a new method of exiting the court became popular. The "politicized departure hypothesis" suggests that Supreme Court Justices began to retire when the political climate favored their replacement with someone like-minded. Thus a conservative Republican Justice would attempt to time his retirement when there was a conservative Republican President in power to replace him with an ideologically similar Justice. The same has been true with Justices who favored the Democratic Party.
The notable exception has been Chief Justice William H. Rehnquist, who died in 2005 leaving an opening in the court. Justice Scalia's death poses a strange situation on the court, as his replacement while President Obama is in office will see that the Supreme Court becomes weighted toward the Democratic Party. A delay in filling the open slot opens the possibility of the court could be either Democratic or Republican depending on the political orientation of the next President.
I have attached a link to a helpful study that attempts to decipher a pattern in the retiring of Supreme Court Justices.