i = gets_to.i while i >= 7 arr[] << i%7 i/=7 end res = arr.join.reverse! puts res