fun readLong(): Long = readLine()!!.toLong() fun max(a: Long, b: Long): Long = if (a>b) a else b fun abs(a: Long): Long = if (a<0) -a else a fun f(a: Long): Long = a/2L fun g(a: Long): Long = 2L*f(a)+a tailrec fun h(a: Long, b: Long, c: Long): Long = if (a > 0) h(f(a), b+f(a), max(c,g(a))) else abs(c-b) fun main(args: Array) { val n: Long = readLong() println(h(n,n,2L*n)) }