 import std.functional,
       std.algorithm,
       std.container,
       std.typetuple,
       std.typecons,
       std.bigint,
       std.string,
       std.traits,
       std.array,
       std.range,
       std.stdio,
       std.conv;

void main() {
  long N = readln.chomp.to!long;
  long ans;

  foreach (t; [9, 6]) {
    long i;
    while (N >= t^^(i+1)) {
      i++;
    }
    N -= t^^i;
    ans++;
  }

  foreach (t; [9, 6, 1]) {
    while (N >= t) {
      N-=t;
      ans++;
    }
  }

  writeln(ans);
}
