Jasmine, Abby, and Amber had $865 altogether. Jasmine spent 2/5 of her money. Abby spent $40, and Amber spent twice as much as Jasmine. If the three friends had the same amount of money left, how much money did Abby have in the beginning?