import scala.io.StdIn

object Main {
  def main(args: Array[String]): Unit = {
    val Array(n, x) = StdIn.readLine.split(' ').map(_.toInt)
    val m1 = (n - x).toDouble * (1.toDouble / 3)
    val m2 = (n - x).toDouble * (2.toDouble / 3)
    println(m1 * 6 + m2 * 3)
  }
}