# python l =input() l = int(l) beki =[] ans = 0 while True: a = l % 7 beki.append(a) l = l // 7 if l / 7 < 7: beki.append(l%7) for num in range(len(beki)): ans += beki[num] * 10**num break print(ans)