The answers above fall into a bit of a trap - the matter is far more complicated than they suggest: as there are at least two plays which we think Shakespeare wrote which have not survived.
Meres writes of "Love's Labour's Won" (a sequel, we think, to "Love's Labour's Lost") and another textual source (Humphrey Mosely) tells us of another lost play "Cardenio". No copies of either has survived.
Some scholars, moreover, think that Shakespeare wrote "Edward III", and it is now generally accepted that he wrote - at least some of - a play called "Sir Thomas More". Scholars disagree about whether the writing (which has survived) is Shakespeare's, or the work of another playwright. Some of the plays - including "Henry VIII" - which we know to be by Shakespeare, were likely also co-written with other writers.
"The Two Noble Kinsmen" is also now - though not included in the First Folio - generally believed to be by Shakespeare.
So the answer depends on who you believe. It's 38 (including "The Two Noble Kinsmen") plus (depending on what you believe) "Edward III" and "Sir Thomas More", and - if they indeed existed - "Cardenio" and "Love's Labour's Won".
So the best scholarly answer at present is 42. But who knows what time will reveal!