import scala.collection.mutable.* import scala.io.StdIn.* import scala.util.chaining.* import scala.math.* import scala.reflect.ClassTag import scala.util.* import scala.annotation.tailrec import scala.collection.mutable extension (value: Int) def toTriple: Long = value.toString.pipe(s => (s + s + s).toLong) @main def main = val n = readLine.toLong var min = 0 var max = 100000 while min < max do val mid = (min + max) >>> 1 if mid.toTriple <= n then min = mid + 1 else max = mid println(max - 1)