I think for 400 hp sedan it is pretty reliable. The drivetrain and engine seem reliable. The electronics are a bit touchy, but this is certainly not unique to the M5...
Most people seem to have only minor issues for the first 50K miles. Then it becomes very variable (how many miles, how many owners, how well it was kept up, how hard it was driven, etc.).
My car is still young, but so far only minor issues/me being picky. I ran the VIN pre-purcahse and found no major repair issues as well.
Long term, I'm sure my 530 would have been more bullet proof, but the M5 is worth it!
As suggested you can do a search, but I would look for a 2001+ model with as low miles as you can find/afford, preferably CPO or with 100K factory warrantee purchased by the original owner. Have a local BMW dealer run the VIN, and get an indepedent inspection no matter who you buy it from. Drive the car before you buy, perferably somewhat hard to check for clutch slippage. In my opinion it is a huge plus to be able to speak to the previous owner, and I personally would only buy a one-owner car (a gross generalization I know).
I would rather put some more money up front to buy a pristine car than put a bunch of money in a short time later...
Good luck!