Ryan had some blue and green buttons. 3/7 of the buttons are blue and the rest were green. He gave away 2/5 of his buttons. 80 of the buttons given away were blue. 2/3 of the buttons left were green. How many buttons did Ryan have altogether at first?