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