At first, Andy had some money. He spent 14 of it on a jacket and 34 of the remainder on a coat. After that, his father 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 Andy have at first?