#!/usr/bin/env perl use strict; use warnings; my $n = <>; chomp $n; my @v; while ($n > 0) { push @v, $n % 7; $n /= 7; $n = int($n); } print $_ for reverse @v;