#!/usr/bin/env python3 n = int(input()) s = [] while n: s += [ n % 7 ] n //= 7 if not s: s += [ 0 ] print(''.join(map(str, reversed(s))))