At first, Oscar had some money. He spent 14 of it on a dress and 27 of the remainder on a sweater. After that, his aunt gave him $340. The ratio of the total amount of money he had in the end to the amount of money he had at first was 5 : 4. How much money did Oscar have at first?