n = gets.chomp.to_i s = [] while n > 0 s.unshift(n % 7) n /= 7 end puts s.join