A grocer bought 24 kg of coffee beans at price X. After a while one third of the stock got spoiled so he sold the rest for 200$ per kilo and made a total profit of twice the cost. What must be price X?