
fun min(a:Int, b:Int):Int = if (a > b) b else a
fun min(a:Long, b:Long):Long = if (a > b) b else a
data class Daunats(val parent:Daunats?, val cost:Int) {
    init {
        parent?.children?.add(this)
    }
    private val children = mutableListOf<Daunats>()
    val descendantsCount:Int by lazy {children.sumBy { it.descendantsCount } + 1}
    val wholeCost:Long by lazy{children.map { it.wholeCost }.sum() + cost }
}
data class Budget(val cost:Long, val value:Int, val count:Int):Comparable<Budget>{
    override fun compareTo(other: Budget): Int {
        return (value * other.cost).compareTo(cost * other.value)
    }
}
fun main(args:Array<String>):Unit{
    val (n, x, d) = readLine()!!.split(' ').map(String::toInt)
    Array<Daunats?>(n){ null }.apply {
        val m = readLine()!!.toInt()
        this[0] = Daunats(null, m)
        for (i in 1 until n){
            val (m, p) =readLine()!!.split(' ').map(String::toInt)
            this[i] = Daunats(this[p - 1], m)
        }
    }.filterNotNull().map{daunats ->  Budget(daunats.wholeCost, daunats.descendantsCount, if (daunats.parent == null) x else d)}.sortedDescending().let{
        val memo = Array(n * n * n + 1){Long.MAX_VALUE}//memo[idx] -> 価値がidxになる組み合わせで最小のコスト
        memo[0] = 0
        for ((cost, value, size) in it){
            var i = 1
            while (i * 2 <= min(n, size)){
                for (idx in (n * n * n - i * value) downTo 0){
                    if (memo[idx] != Long.MAX_VALUE){
                        memo[idx + i * value] = min(memo[idx + i * value], memo[idx] + i * cost)
                    }
                }
                i *= 2
            }
            i = min(n, size) - i + 1
            for (idx in (n * n * n - i * value) downTo 0){
                if (memo[idx] != Long.MAX_VALUE){
                    memo[idx + i * value] = min(memo[idx + i * value], memo[idx] + i * cost)
                }
            }
        }
        var max:Long = 0
        for ((value, minM) in memo.withIndex()){
            if (minM != Long.MAX_VALUE && minM <= x){
                var restCost = x - minM
                var tempValue = value.toLong()
                for ((c, v, s) in it){
                    tempValue += min(restCost / c, s.toLong() - min(s, n)) * v
                    restCost -= min(restCost / c, s.toLong() - min(s, n)) * c
                }
                if (tempValue > max) max = tempValue
            }
        }
        println(max)
    }
}