No one knows exactly because drug companies are allowed to count many of their marketing expenses are part of their R&D. For example, phase IV trials are mostly done as marketing as an excuse to bribe doctors with tens of thousands of dollars to put patients on the drugs in exchange for answering one or two questions about their opinions on the drug that are completely unscientific and unpublishable.
That said to get a drug through phase III trials shouldn't cost more than about $20 million. You can go to MAPS webpage and see their budget and how much they are projecting it's going to cost to get MDMA approved. The reason the pharma companies claim that it takes billions per new drug to develop is that they're basically counting marketing expenses, other failed drugs, regulatory fines, etc.