import scala.io.StdIn.readLine import scala.collection.mutable.PriorityQueue import scala.annotation.tailrec object Main { def solve(n : Long) : Int = { val fermat_numbers = List[Long](3, 5, 17, 257, 65537) def big(c : Set[Long],k : Long) : Set[Long] = { c.withFilter(_*k <= n).map(_*k) ++ c } val init = (0l to Math.ceil(Math.log(n)/Math.log(2)).toLong). map((k) => Math.round(Math.pow(2,k)).toLong).toSet val drawables_in_n = fermat_numbers.foldLeft(init)(big(_,_)).filter((i) => 3 <= i && i <= n) drawables_in_n.size } def main(args : Array[String]) : Unit = { val n = readLine().toLong println(solve(n)) } }