<?php
$handle = fopen("php://stdin", "r"); $sad = 0;
for ($i = 0; $i < $n; $i++){
$sign = $line[0];
if($sign === "+"){
$x += $d;
} else {
if($x >= $d){
$x -= $d;
} else {
$sad++;
}
}
}
echo $x . " " . $sad;
?>
PD9waHAKJGhhbmRsZSA9IGZvcGVuKCJwaHA6Ly9zdGRpbiIsICJyIik7Cmxpc3QoJG4sICR4KSA9IGFycmF5X21hcCgnaW50dmFsJywgZXhwbG9kZSgiICIsIHRyaW0oZmdldHMoJGhhbmRsZSkpKSk7CiRzYWQgPSAwOwpmb3IgKCRpID0gMDsgJGkgPCAkbjsgJGkrKyl7CiAgICAkbGluZSA9IGV4cGxvZGUoIiAiLCB0cmltKGZnZXRzKCRoYW5kbGUpKSk7CiAgICAkc2lnbiA9ICRsaW5lWzBdOwogICAgJGQgPSBpbnR2YWwoJGxpbmVbMV0pOwogICAgaWYoJHNpZ24gPT09ICIrIil7CiAgICAgICAgJHggKz0gJGQ7CiAgICB9IGVsc2UgewogICAgICAgIGlmKCR4ID49ICRkKXsKICAgICAgICAgICAgJHggLT0gJGQ7CiAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgJHNhZCsrOwogICAgICAgIH0KICAgIH0KfQplY2hvICR4IC4gIiAiIC4gJHNhZDsKPz4K