<?php
fscanf(STDIN, "%d %d", $numKatana, $monsterHp);
    for($i = 0; $i < $numKatana; $i++){
        fscanf(STDIN, "%d %d", $shakeDmg, $throwDmg);
        $shakeDmgs[] = $shakeDmg;
        $throwDmgs[] = $throwDmg;
    }

    $maxShakeDmg = max($shakeDmgs);

    $bigThrowDmgs = array_filter($throwDmgs,
        function ($throwDmgs) use ($maxShakeDmg) {
            return $throwDmgs > $maxShakeDmg;
        });

    $totalThrowDmg = array_sum($bigThrowDmgs);
    $monsterHpAfterThrow = $monsterHp - $totalThrowDmg;

    $numAttack = ceil($monsterHpAfterThrow / $maxShakeDmg) + count($bigThrowDmgs);
    var_dump($numAttack);
