#include <cstdio>
#include <iostream>
#include <string>
#include <limits>
#include <algorithm>

using namespace std;
#define DEBUG(X) cerr<<__LINE__<<" "<<#X<<": "<<X<<endl;
#define sci(x) int x;scanf("%d",&x);
#define scii(x, y) int x,y;scanf("%d%d",&x,&y);

template<typename TypeInt>
std::string Itoa(const TypeInt v, int base)
{
  static const char table[] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
  string ret;
  static numeric_limits<TypeInt> t;
  TypeInt n = v;
  if (t.is_signed) {
    if (v < 0) n *= -1;
  }

  while (n >= base) {
    ret += table[n%base];
    n /= base;
  }
  ret += table[n];
  if (t.is_signed) {
    if (v < 0 && base == 10) ret += '-';
  }
  // 文字列の順番を逆にする
  std::reverse(ret.begin(), ret.end());

  return ret;
}

int main(){
  sci(N)
  cout << Itoa(N, 7) << endl;
}