
fun main(args:Array<String>): Unit {
    while(true) {
        val (n, m) = readLine()!!.trim().split(' ').map(String::toLong)
        if (n == 0L && m == 0L) return
        val probability = probabilities(n.toInt())
        val prospects = probability.mapIndexed { index, d -> index * d }.toDoubleArray().also {
            for (i in (1 until it.size).reversed()) it[i - 1] += it[i]
        }
        for (i in 1 until probability.size) probability[i] += probability[i - 1]
        var count = m - 1
        var current = 3.5 * n
        while (count != 0L && current < 6 * n) {
            val next = binSearch(current, count, prospects, probability)
            count = next.second
            current = next.first
        }
        println(current)
    }
}
fun exponent(n:Int): Long {
    return when(n){
        0 -> 1
        else -> 6 * exponent(n - 1)
    }
}
fun probabilities(n: Int): DoubleArray {
    val res = LongArray(6 * n + 1){0L}.also{it[0] = 1}
    repeat(n){
        for (i in (0 until res.size).reversed()){
            if (res[i] > 0){
                for (j in 1 .. 6){
                    res[i + j] += res[i]
                }
                res[i] = 0
            }
        }
    }
    val all = exponent(n)
    return res.map{it.toDouble() / all}.toDoubleArray()
}

class Matrix2x2(private val array: DoubleArray) {
    operator fun get(row: Int, column: Int): Double = array[row * 2 + column]
    operator fun times(matrix: Matrix2x2): Matrix2x2 {
        return Matrix2x2(
                doubleArrayOf(
                        array[0] * matrix.array[0] + array[1] * matrix.array[2],
                        array[0] * matrix.array[1] + array[1] * matrix.array[3],
                        array[2] * matrix.array[0] + array[3] * matrix.array[2],
                        array[2] * matrix.array[1] + array[3] * matrix.array[3]
                )
        )
    }
}
fun exponent(matrix: Matrix2x2, exp: Long): Matrix2x2 {
    return when(exp){
        0L -> Matrix2x2(doubleArrayOf(1.0, 0.0, 0.0, 1.0))
        1L -> matrix
        else -> exponent(matrix, exp / 2).let{if (exp % 2 == 0L) it * it else it * it * matrix}
    }
}
fun binSearch(sm: Double, count: Long, prospects: DoubleArray, probability: DoubleArray): Pair<Double, Long> {
    val matrix = Matrix2x2(
            doubleArrayOf(
                    probability[sm.toInt()], prospects[(sm + 1).toInt()], 0.0, 1.0
            )
    )
    val target = (sm + 1).toInt()
    var left = 0L
    var right = count
    while (left < right){
        val mid = (left + right) / 2
        val m = exponent(matrix, mid)
        if (m[0, 0] * sm + m[0, 1] >= target){
            right = mid
        }else{
            left = mid + 1
        }
    }
    val m = exponent(matrix, right)
    return (m[0, 0] * sm + m[0, 1] to count - right)
}
