n=gets.to_i

# 18 -> 24

if n.zero?
  puts 0
  exit(0)
end

ans=[]
while n.nonzero?
  ans<< n%7
  n/=7
end

puts ans.reverse.join("")