The e39 M5 is actually super reliable if it has been maintained and not abused. Maintenance records and PPI are a must with this car and I would have a full ECU dump done to show Max Revs for the engine. 50K is right about where alot of things on the M5 tend to wear out. CPS(4 of them) and Mafs tend to go around 50k on average and brake jobs can be spendy. A Peak code reader should be your first purchase if you buy the car and then hop on m5board.com and show us pics. If is super clean and well taken care of 18K is OK. Lots of these cars going on the market....
2004 E46 330xi
2002 E39 M5