#include using namespace std; typedef long long ll; int main() { int n; cin>>n; ll ans = 0; ll d=1; while (n) { ans += n%7*d; d *= 10; n /= 7; } cout << ans << endl; return 0; }