Vasya has recently learned to type and log on to the Internet. He immediately entered a chat room and decided to say hello to everybody. Vasya typed the word s. It is considered that Vasya managed to say hello if several letters can be deleted from the typed word so that it resulted in the word "hello". For example, if Vasya types the word "ahhellllloou", it will be considered that he said hello, and if he types "hlelo", it will be considered that Vasya got misunderstood and he didn't manage to say hello. Determine whether Vasya managed to say hello by the given word s.

The first and only line contains the word s, which Vasya typed. This word consisits of small Latin letters, its length is no less that 1 and no more than 100 letters.

If Vasya managed to say hello, print "YES", otherwise print "NO".

<?php
while (fscanf(STDIN, "%s", $string)){
    $length = strlen($string);
    $s = 'hello';
    $s_i = 0;
    for ($i = 0; $i < $length; ++$i){
        if ($s[$s_i] == $string[$i]){
            if ($s[$s_i] == 'o'){
                echo "YES\n";
                $s_i = -1;
                break;
            }
            ++$s_i;
        }
    }

    if ($s_i != -1){
        echo "NO\n";
    }
}

<?php
error_reporting("off");
//58A: Chat room
//I guess I'm bruteforcing. haha.
$echoed = FALSE;
$input = trim(fgets(STDIN)); //$input = "o";
if (strpos($input, "h") === FALSE) {
    echo "NO";
    $echoed = TRUE;
}
$input = substr($input, strpos($input, "h"));
if (strpos($input, "e") === FALSE) {
    if ($echoed == FALSE) {
        echo "NO";
        $echoed = TRUE;
    }
}
$input = substr($input, strpos($input, "e"));
if (strpos($input, "l") === FALSE) {
    if ($echoed == FALSE) {
        echo "NO";
        $echoed = TRUE;
    }
}
$input = substr($input, strpos($input, "l") + 1); //doing it differently (not semantic (actually this whole program is not semantic)) by taking off that l too.
if (strpos($input, "l") === FALSE) {
    if ($echoed == FALSE) {
        echo "NO";
        $echoed = TRUE;
    }
}
$input = substr($input, strpos($input, "l"));
if (strpos($input, "o") === FALSE) {
    if ($echoed == FALSE) {
        echo "NO";
        $echoed = TRUE;
    }
}

if ($echoed === FALSE) {
    echo "YES";
}
?>

<?php
$hello = trim(fgets(STDIN));
echo preg_match("/.*h.*e.*l.*l.*o.*/",$hello) ? "YES": "NO";
?>

<?
	define("_", PHP_EOL);
	$MAX_N = PHP_INT_MAX;
	$L = trim(fgets(STDIN));
	echo preg_match("/.*h.*e.*l.*l.*o.*/", $L) ? "YES" : "NO";
?>

<?php
$s = trim(fgets(STDIN));

echo preg_match("/.*h.*e.*l.*l.*o.*/",$s) ? "YES": "NO";
?>

<?php

$input = fopen('php://stdin', 'r');
fscanf($input, "%s", $input);

$search = 'hello';
$searchArray = str_split($search);

$inputArray = str_split($input);
$dump = array();
foreach($inputArray as $item)
{
    if($item == $searchArray[count($dump)])
        array_push($dump, $item);
}

$diff1 = count(array_diff($dump, $searchArray));
$diff2 = count(array_diff($searchArray, $dump));

if($diff1 == 0 AND $diff2 == 0)
    echo 'YES';
else
    echo 'NO';

<?php
	$input_line = trim(fgets(STDIN));
	echo preg_match('/h.*e.*l.*l.*o/', $input_line)?"YES":"NO";
?>

<?php
    $input = trim(fgets(STDIN));
    //$arr = explode(' ', $input);

    if (strlen($input) < 5) {
        echo 'NO';exit;
    }

    $a = ['h','e','l','l','o'];
    $b = str_split($input);

    foreach ($b as $v) {
        if ($v == current($a)) {
            array_shift($a);
            if (count($a) === 0) {
                echo 'YES';exit;
            }
        }
    }

    echo 'NO';exit;

<?php
    $str = trim(fgets(STDIN));

    $h = strpos($str, 'h');
    $e = strpos($str, 'e', $h+1);
    $l = strpos($str, 'l', $e+1);
    $l2 = strpos($str, 'l', $l+1);
    $o = strpos($str, 'o', $l2+1);

    if($h < $e && $e < $l && $l < $l2 && $l2 < $o) echo "YES";
    else echo "NO";

?>

<?php

function dd(...$args)
{
    var_dump(...$args);
    die;
}

define('TXTIN', fopen('input.txt', 'r'));
define('TXTOUT', fopen('output.txt', 'w'));

//$input = TXTIN;
$input = STDIN;
//$output = TXTOUT;
$output = STDOUT;

function foo($s)
{
    $h = $e = $l1 = $l2 = $o = false;

    for ($i = 0; $i < strlen($s); $i++) {
        if ($s[$i] === 'h' && !$h) {
            $h = true;
            continue;
        }

        if ($s[$i] === 'e' && !$e && $h) {
            $e = true;
            continue;
        }

        if ($s[$i] === 'l' && !$l1 && $h && $e) {
            $l1 = true;
            continue;
        }

        if ($s[$i] === 'l' && !$l2 && $h && $e && $l1) {
            $l2 = true;
            continue;
        }

        if ($s[$i] === 'o' && !$o && $h && $e && $l1 && $l2) {
            $o = true;
            continue;
        }
    }

//    dd($h, $e, $l1, $l2, $o);
    return $h && $e && $l1 && $l2 && $o;
}

$r = 0;

list($s) = fscanf($input, "%s\n");

$r = foo($s) ? 'YES' : 'NO';

fwrite($output, $r);

<?
$word = fopen("php://stdin", 'r');
$str = fread($word, 100);
$pattern = "/.*h.*e.*l.*l.*o/";

if (preg_match($pattern, $str) > 0){
        echo "YES";
} else {
        echo "NO";
}
?>

<?php echo preg_match('/h.*e.*l.*l.*o/si', fgets(STDIN)) ? 'YES' : 'NO';

<?php
$a=trim(fgets(STDIN));
$b="hello";
$j=0;
for($i=0;$i<strlen($a);++$i)
    if ($a[$i]==$b[$j])
    {
        $j++;
        if ($j==5)
            break;
    }
if ($j==5)
    printf("YES\n");
else
    printf("NO\n");
?>

<?php
$s = str_split(readline());
$test = ['h', 'e', 'l', 'l', 'o'];
$i= 0;
foreach($s as $letter){
    if($letter == $test[$i]){
        $i++;
        if($i == 5){
            break;
        }
    }
}

if($i == 5){
    echo "YES";
}else{
    echo "NO";
}

<?php
$line = str_split(strtolower(fgets(STDIN)),1);
$hello = array("h","e","l","l","o");
$j=0;
for ($i=0;$i<count($line);$i++)
{
    if ($line[$i]==$hello[$j])
    {
        $j++;
    }
    if ($j==5)break;
}
if ($j<5)echo "NO";
else echo "YES";

<?php

$str = fgets(STDIN);
$str_arr = preg_split('//', $str, -1, PREG_SPLIT_NO_EMPTY);
$word = array('h','e','l','l','o');
$i = 0;
$j = 0;
$k = 0;
$ch = 0;
for ($i = 0; $i < count($word); $i++) {
    for ($j = $k; $j < count($str_arr); $j++) {
        if ($word[$i] == $str_arr[$j]) {
            $k = $j + 1;
            $ch = $ch + 1;
            break;
        } else {
            //
        }
    }
}
if ($ch == count($word)) {
    print("YES");
} else {
    print("NO");
}

<?php
$input=str_split(fgets(STDIN));
$count=count($input);
for ($i=0; $i <$count;$i++) {
      if($input[$i] == 'h'){
            for ($j=$i+1; $j<$count;$j++) {
                  if ($input[$j] == 'e') {
                        for ($t=$j+1; $t <$count;$t++) {
                              if ($input[$t] == 'l') {
                                    for ($d=$t+1; $d <$count ; $d++) {
                                          if ($input[$d] == 'l') {
                                                for ($f=$d+1; $f <$count; $f++) {
                                                      if ($input[$f] == 'o') {
                                                            echo "YES";
                                                            return false;
                                                      }
                                                }
                                          }
                                    }
                              }
                        }
                  }
            }
      }
}
echo "NO";
?>

<?php
$line = fgets(STDIN);
echo (preg_match('/^.*h.*e.*l.*l.*o.*$/i', $line)) ? 'YES' : 'NO';
?>

<?php
$str=trim(fgets(STDIN));
$word="hello";
$j=0;
for ($i=0; $i <strlen($str) ; $i++)
{
	if($str[$i]==$word[$j])
    {
		//echo "$str[$i] $word[$j]\n";
		$j++;
     if($j==5)
     	break;

	}
}
echo $j==5?"YES":"NO";

<?php
$f = fopen('php://stdin', 'r');
//$f = fopen('test.txt', 'r');

$s = trim(fgets($f));
preg_match("/.*h.*e.*l.*l.*o.*/",$s,$match);

if (count($match)>0) echo "YES";
else echo "NO";

<?php

fscanf(STDIN, "%s\n", $s);
$s = strtolower($s);
$chars = str_split($s, 1);

$got_h = 0;
$got_e = 0;
$got_l = 0;
$got_l2 = 0;
$got_o = 0;

$word_arr = array('h', 'e', 'l', 'l', 'o');
$parsed_str = "";

foreach ($chars as $char) {
   if (in_array($char, $word_arr)){
      $parsed_str .= $char;
   }
}
# get rid of repeating h
$parsed_str = preg_replace('/[h][h]*/', 'h', $parsed_str);
# get rid of repeating e
$parsed_str = preg_replace('/[e][e]*/', 'e', $parsed_str);
# get rid of repeating l (more than 2)
$parsed_str = preg_replace('/[l][l][l]*/', 'll', $parsed_str);
# get rid of repeating o
$parsed_str = preg_replace('/[o][o]*/', 'o', $parsed_str);

//echo $parsed_str . "\n";

if ($parsed_str == 'hello') {
   echo "YES";
}
else {
   $parsed_chars = str_split($parsed_str, 1);
   $pword_arr = array("h" => 0, "e" => 0, "l" => 0, "o" => 0);
   foreach ($parsed_chars as $pchar) {
      if ($pchar == 'h' && $got_h == 0) {
         //echo "found first h\n";
         $got_h = 1;
         $got_e = 0;
         $got_l = 0;
         $got_l2 = 0;
         $got_o = 0;
        continue;
      }

      if ($pchar == 'e' && $got_h && !$got_e) {
         //echo "found first e\n";
         $got_e = 1;
        continue;
      }

      if ($pchar == 'l' && $got_h && $got_e && !$got_l){
         //echo "found first l\n";
         $got_l = 1;
        continue;
      }

      if ($pchar == 'l' && $got_h && $got_e && $got_l && !$got_l2) {
         //echo "found second l\n";
         $got_l2 = 1;
        continue;
      }

      if ($pchar == 'o' && $got_h && $got_e && $got_l && $got_l2 && !$got_o) {
         //echo "found first o\n";
         $got_o = 1;
        continue;
      }
   }

   if ($got_h && $got_e && $got_l && $got_l2 && $got_o) {
      echo "YES";
   }
   else {
      echo "NO";
   }
}
?>

<?php
$text = file_get_contents("php://stdin");
echo preg_match("/h.*e.*l[^l]*l.*o/", $text)?"YES":"NO";

<?php
$str = fgets(STDIN);

if (preg_match('/h.*e.*l.*l.*o/', $str))
{
    echo 'YES';
}
else
{
    echo 'NO';
}

<?php
$s = trim(fgets(STDIN));
echo (preg_match("/h.*e.*l.*l.*o/", $s) ? "YES" : "NO");
?>

<?php
$a=trim(fgets(STDIN));
if( preg_match('/.*h.*e.*l.*l.*o.*/',$a) ) echo "YES"; else echo "NO";

?>

<?php
    echo preg_match('/h.*e.*l.*l.*o/', file_get_contents('php://stdin')) ? 'YES' : 'NO';
?>

<?php

//First Get The Input.
$input = file_get_contents("php://stdin");

function func ($input) {

    //"hello" Word.
    $word = "hello";

    //Current Index.
    $current_index = 0;

    //Loop Inside The Given String.
    for($i = 0;$i < strlen($input);$i++) {

        if($word[$current_index] == $input[$i]) {

            $current_index++;

        }

    }

    if($current_index >= strlen($word)) {

        return "YES";

    }else {

        return "NO";

    }

}

echo func($input);

?>

<?php
$s = trim(fgets(STDIN));
echo (preg_match("/h.*e.*l.*l.*o/", $s) ? "YES" : "NO");

?>

<?php
// 58A Чат

$in = fopen("php://stdin", 'r');

$input_line = fgets($in);

if (preg_match("/.*h.*e.*l.*l.*o.*/i", $input_line)) {
//if (preg_match("/[.]*h[.]*e[.]*l[.]*l[.]*o[.]*/U", $input_line)) {
    echo "YES";
} else {
    echo "NO";
}

?>

<?php
// 58A Чат

$in = fopen("php://stdin", 'r');

$input_line = fgets($in);

if (preg_match("/.*?h.*?e.*?l.*?l.*?o.*?/i", $input_line)) {
//if (preg_match("/[.]*h[.]*e[.]*l[.]*l[.]*o[.]*/U", $input_line)) {
    echo "YES";
} else {
    echo "NO";
}

?>

<?php
    $str = trim(fgets(STDIN));
    echo (preg_match("/[a-z]*h[a-z]*e[a-z]*l[a-z]*l[a-z]*o[a-z]*/", $str) ? "YES" : "NO");
?>

<?php
$str=trim(fgets(STDIN));
function hellow($str){
    preg_match("/h.*?e.*?l.*?l.*?o/",$str,$m);
    if(!empty($m)) return "YES";
    return "NO";
}
echo hellow($str);
?>

<?php

fscanf(STDIN, '%s\n', $s);
$line = str_split($s);
$counter = 0;

$wordToFind = 'hello';
$letterToFind = $wordToFind[0];

for($i = 0; $i < count($line); $i++) {
	if($line[$i] == $letterToFind) {
		$counter++;
		$letterToFind = $wordToFind[$counter];
	}
}

if ($counter == 5) {
	printf('YES');
} else {
	printf('NO');
}

<?php
   fscanf(STDIN, "%s", $str);

   $hello = "hello";
   $n = 0;

   for($i = 0; $i < strlen($str); $i++)
      if($str[$i] == $hello[$n]) $n++;

   if ($n == 5) echo("YES");
   else echo("NO");
?>

<?php
error_reporting(0);
fscanf(STDIN, "%s", $type);
$base = "hello";
$count = 0;
$a = 0;
for ($i = 0; $i < strlen($type); $i++) {
    if ($type[$i] == $base[$a]) {
        $a++;
        $count++;
    }
}
if ($count == 5) {
    echo "YES\n";
} else {
    echo "NO\n";
}

<?php
fscanf(STDIN,'%s', $s);
$a = 'hello';
$count = 0;
for ($i=0;$i<strlen($s);$i++){
    if ($s[$i] == $a[$count]){
        $count++;
        if($count == 5)
            break;
    }
}
if ($count == 5)
    echo 'YES';
else
    echo 'NO';
?>

<?
$s=trim(fgets(STDIN));
$h= stripos($s,"h");
$e= stripos(substr($s,$h),"e");
$l= stripos(substr($s,$h+$e),"l");
$l2= stripos(substr($s,$h+$e+$l+1),"l");
$o= stripos(substr($s,$h+$e+$l+$l2+1),"o");
If($h === false or $e === false or $l === false or $l2 === false or $o === false)echo "NO";
else echo "YES";
?>

<?php
$s = trim(fgets(STDIN));

print preg_match('/h.*e.*l.*l.*o/',$s,$o)?'YES':'NO';
?>

<?php
error_reporting(-1);

if (preg_match('/h.*e.*l.*l.*o/', file_get_contents('php://stdin')))
	echo 'YES', PHP_EOL;
else
	echo 'NO', PHP_EOL;

<?php
while(fscanf(STDIN,"%s",$str)){
    $len = strlen($str);
    $key = "hello";
    $k = 0;
    $a = 0;
    for($i = 0; $i < $len; ++$i){
        if($str[$i] == $key[$k])
            ++$k;
        if($k == 5){
            echo "YES\n";
            break;
        }
    }
    if($k != 5)
      echo "NO\n";
}

<?php
$cin = fopen('php://stdin', 'r');

fscanf($cin, "%s", $str);

$hello = "hello";
$idx = 0; $i = 0;

while($idx < strlen($hello) && $i < strlen($str)){
    if($hello[$idx] == $str[$i]) $idx++;
    $i++;
}

echo ($idx >= strlen($hello) ? "YES" : "NO");

?>

<?
$fp=fopen('php://stdin', 'r');
$lines=stream_get_contents($fp);

$lines=trim($lines);

$tpl="hello";

$ok=true;
$i=-1;
$n=0;
while (++$i<strlen($lines))
{
    $char=$lines{$i};
    if ($char==$tpl{$n})
        $n++;
    if ($n==strlen($tpl))
    {
        echo 'YES';
        die;
        break;
    }
}

echo 'NO';
?>

<?php
$line = fgets(STDIN);
echo preg_match("/.*h.*e.*l.*l.*o.*/",$line)?"YES":"NO";
?>

<?php
	$var = str_split(fgets(STDIN));
	$flag = 0;
	$comp = array('h','e','l','l','o');
	foreach ($var as $v) {
		if ($v == $comp[$flag]) {
			$flag++;
		}
		if ($flag == 5) break;
	}
	if ($flag == 5) echo 'YES';
	else echo 'NO';

<?php
while (fscanf(STDIN, "%s", $string)){
    $length = strlen($string);
    $s = 'hello';
    $s_i = 0;
    for ($i = 0; $i < $length; ++$i){
        if ($s[$s_i] == $string[$i]){
            if ($s[$s_i] == 'o'){
                echo "YES\n";
                break;
            }
            ++$s_i;
        }
    }
    if ($s_i != 4){
        echo "NO\n";
    }
}

<?php
error_reporting("off");
//58A: Chat room
//I guess I'm bruteforcing. haha.
$echoed = FALSE;
$input = trim(fgets(STDIN)); //$input = "hlelo";
if (strpos($input, "h") === FALSE) {
    echo "NO";
    $echoed = TRUE;
}
$input = substr($input, strpos($input, "h"));
if (strpos($input, "e") === FALSE) {
    echo "NO";
    $echoed = TRUE;
}
$input = substr($input, strpos($input, "e"));
if (strpos($input, "l") === FALSE) {
    echo "NO";
    $echoed = TRUE;
}
$input = substr($input, strpos($input, "l") + 1); //doing it differently (not semantic (actually this whole program is not semantic)) by taking off that l too.
if (strpos($input, "l") === FALSE) {
    echo "NO";
    $echoed = TRUE;
}
$input = substr($input, strpos($input, "l"));
if (strpos($input, "o") === FALSE) {
    echo "NO";
    $echoed = TRUE;
}

if ($echoed === FALSE) {
    echo "YES";
}
?>

<?php
error_reporting("off");
//58A: Chat room
//I guess I'm bruteforcing. haha.
$no = FALSE;

$input = trim(fgets(STDIN)); //$input = "hlelo";
if (strpos($input, "h") === FALSE) {
    $no == TRUE;
}
$input = substr($input, strpos($input, "h"));
if (strpos($input, "e") === FALSE) {
    $no == TRUE;
}
$input = substr($input, strpos($input, "e"));
if (strpos($input, "l") === FALSE) {
    $no == TRUE;
}
$input = substr($input, strpos($input, "l") + 1); //doing it differently (not semantic (actually this whole program is not semantic)) by taking off that l too.
if (strpos($input, "l") === FALSE) {
    $no == TRUE;
}
$input = substr($input, strpos($input, "l"));
if (strpos($input, "o") === FALSE) {
    $no == TRUE;
}

if ($no === TRUE) {
    echo "NO";
} else {
    echo "YES";
}
?>

<?php
	$input_line = trim(fgets(STDIN));
	echo preg_match('/h*e*l*l*o/', $input_line)?"YES":"NO";
?>

<?php
	$input_line = trim(fgets(STDIN));
	echo preg_match('/.h*.e*.l*.l*.o/', $input_line)?"YES":"NO";
?>

<?php
    $str = trim(fgets(STDIN));

    $h = strpos($str, 'h');
    $e = strpos($str, 'e');
    $ll = strpos($str, 'll');
    $o = strpos($str, 'o');

    if($h < $e && $e < $ll && $ll < $o) echo "YES";
    else echo "NO";

?>

<?php
    $str = trim(fgets(STDIN));

    $h = strpos($str, 'h');
    $e = strpos($str, 'e');
    $l = strpos($str, 'l');
    $l2 = strpos($str, 'l', $l+1);
    $o = strpos($str, 'o');

    if($h < $e && $e < $l && $l < $l2 && $l2 < $o) echo "YES";
    else echo "NO";

?>

<?php
$s = trim(fgets(STDIN));
while(1) {
    $s1 = preg_replace(array('/hh/','/ee/','/lll/','/oo/') , array('h','e','ll','o'), $s);
    if(strcmp($s, $s1)===0) {
        $s = $s1;
        unset($s1);
        break;
    }
    $s = $s1;
}
if(strlen(str_replace('hello', '', $s)) != strlen($s)) {
    echo('YES');
    exit(0);
}
else {
    echo('NO');
}

$word = fopen("php://stdin", 'r');
$pattern = "/.*h.*e.*l.*l.*o/";

if (preg_match($pattern, $word) > 0){
    echo "YES";
} else {
    echo "NO";
}

<?php
$line = fgets(STDIN);
echo (preg_match('/^.*h.*e.*l.*l.*o.*$/i')) ? 'YES' : 'NO';
?>

<?php
$str=trim(fgets(STDIN));
$hello="hello";
for($i=0;$i<strlen($hello);$i++)
{
	for($j=0;$j<strlen($str);$j++)
	{
		if($hello[$i]==$str[$j])
		{
			$count[$i]=$j;
			break;
		}

	}
}

$cnt=0;
for($i=0;$i<count($count)-1;$i++)
{
 if($count[$i]>$count[$i+1]){
 	echo "NO";
 	break;
 }
 else $cnt++;

}
if($cnt==4)
	echo "YES";

<?php
$str=trim(fgets(STDIN));
for($i=0;$i<strlen($str)-1;$i++)
{
	$str4[$i]=$str[$i].$str[$i+1];
}
//print_r($str4);

$str3="hello";
$accumulate="";
for($i=0;$i<strlen($str3)-1;$i++)
{
	$str5[$i]=$str3[$i].$str3[$i+1];
	$accumulate.=$str5[$i];
}
//echo "$accumulate\n";
//print_r($str5);

$str6="";
for($i=0;$i<count($str5);$i++)
{
	for($j=0;$j<count($str4);$j++)
	{
		if($str5[$i]==$str4[$j])
		{
          $str6.=$str4[$j];
          break;
		}
	}
}

if($accumulate==$str6)
	echo "YES";
else
	echo "NO";

<?php

fscanf(STDIN, "%s\n", $s);
$s = strtolower($s);
$chars = str_split($s, 1);

$got_h = 0;
$got_e = 0;
$got_l = 0;
$got_l2 = 0;
$got_o = 0;

$word_arr = array('h', 'e', 'l', 'l', 'o');
$parsed_str = "";

foreach ($chars as $char) {
   if (in_array($char, $word_arr)){
      $parsed_str .= $char;
   }
}
# get rid of repeating h
$parsed_str = preg_replace('/[h][h]*/', 'h', $parsed_str);
# get rid of repeating e
$parsed_str = preg_replace('/[e][e]*/', 'e', $parsed_str);
# get rid of repeating l (more than 2)
$parsed_str = preg_replace('/[l][l][l]*/', 'll', $parsed_str);
# get rid of repeating o
$parsed_str = preg_replace('/[o][o]*/', 'o', $parsed_str);

if ($parsed_str == 'hello') {
   echo "YES";
}
else {
   echo "NO";
}
?>

<?php

fscanf(STDIN, "%s\n", $s);
$s = strtolower($s);
$chars = str_split($s, 1);

$got_h = 0;
$got_e = 0;
$got_l = 0;
$got_l2 = 0;
$got_o = 0;

$word_arr = array('h', 'e', 'l', 'l', 'o');
$parsed_str = "";

foreach ($chars as $char) {
   if (in_array($char, $word_arr)){
      $parsed_str .= $char;
   }
}
# get rid of repeating h
$parsed_str = preg_replace('/[h][h]*/', 'h', $parsed_str);
# get rid of repeating e
$parsed_str = preg_replace('/[e][e]*/', 'e', $parsed_str);
# get rid of repeating l (more than 2)
$parsed_str = preg_replace('/[l][l][l]*/', 'll', $parsed_str);
# get rid of repeating o
$parsed_str = preg_replace('/[o][o]*/', 'o', $parsed_str);

//echo $parsed_str . "\n";

if ($parsed_str == 'hello') {
   echo "YES";
}
else {
   $parsed_chars = str_split($parsed_str, 1);
   $pword_arr = array("h" => 0, "e" => 0, "l" => 0, "o" => 0);
   foreach ($parsed_chars as $pchar) {
      if ($pchar == 'h' && $got_h == 0) {
         //echo "found first h\n";
         $got_h = 1;
         $got_e = 0;
         $got_l = 0;
         $got_l2 = 0;
         $got_o = 0;
      }

      if ($pchar == 'e' && $got_h && !$got_e) {
         //echo "found first e\n";
         $got_e = 1;
      }

      if ($pchar == 'l' && $got_h && $got_e && !$got_l){
         //echo "found first l\n";
         $got_l = 1;
      }

      if ($pchar == 'l' && $got_h && $got_e && $got_l && !$got_l2) {
         //echo "found second l\n";
         $got_l2 = 1;
      }

      if ($pchar == 'o' && $got_h && $got_e && $got_l && $got_l2 && !$got_o) {
         //echo "found first o\n";
         $got_o = 1;
      }
   }

   if ($got_h && $got_e && $got_l && $got_l2 && $got_o) {
      echo "YES";
   }
   else {
      echo "NO";
   }
}
?>

<?php
$text = file_get_contents("php://stdin");
preg_match("/h.*e.*l[^l]*l.*o/", $text);

<?php
$h = fopen("php://input");
echo fgets($h);

<?php
$stdin = file_get_contents('php://stdin');
echo preg_match('/h+.*e+.*(:?ll+)|(:?l+.*l+).*o+.*u+/', $stdin) ? "YES" : "NO";

<?php
$str = file_get_contents("php://input");
if(preg_match('/h+e+l+o+u+/', $str)) print("YES");
else print("NO");

<?php
$stdin = file_get_contents('php://stdin');
echo preg_match('/h+.*e+.*(:?(:?ll+)|(:?l+.*l+)).*o+.*u+/', $stdin) ? "YES" : "NO";

<?php
$stdin = file_get_contents('php://stdin');
echo preg_match('/h+e+l+l+o+u+/', $stdin) ? "YES" : "NO";

<?php
$stdin = file_get_contents('php://stdin');
echo $stdin;

<?php
$n = trim(fgets(STDIN));
echo (preg_match("/h.*e.*l.*l.*o/", $s) ? "YES" : "NO");
?>

<?php
$input = explode("\n", trim(file_get_contents("php://stdin")));
echo preg_match('/h{1,}e{1,}l{2,}o{1,}/', $input[0]) ? 'YES' : 'NO';

<?php
$s = trim(fgets(STDIN));
echo preg_match("/h . *e . *l . *l. *o/", $s) ? "YES" : "NO";

?>

<?php
// 58A Чат

$in = fopen("php://stdin", 'r');

$input_line = fgets($in);

if (preg_match("/[.]*h[.]*e[.]*l[.]*l[.]*o[.]*/iU", $input_line)) {
    echo "YES";
} else {
    echo "NO";
}

?>

<?php
// 58A Чат

$in = fopen("php://stdin", 'r');

$input_line = fgets($in);

if (preg_match("/[.]*h[.]*e[.]*l[.]*l[.]*o[.]*/i", $input_line)) {
    echo "YES";
} else {
    echo "NO";
}

?>

<?php
// 58A Чат

$in = fopen("php://stdin", 'r');

$input_line = fgets($in);

if (preg_match("/[.]*h[.]*e[.]*l[.]*l[.]*o[.]*/", $input_line)) {
    echo "YES";
} else {
    echo "NO";
}

?>

<?php
$str=trim(fgets(STDIN));
function hellow($str){
    preg_match("/h{1,}e{1,}l{2,}o{1,}/",$str,$m);
    if(!empty($m)) return "YES";
    return "NO";
}
echo hellow($str);
?>

<?php
fscanf(STDIN, '%s', $s);

$arr = array('h', 'e', 'l', 'o');
for ($i = 0; $i < strlen($s); $i++) {
    $flag = false;
    for ($j = 0; $j < count($arr); $j++) {
        if ($s[$i] == $arr[$j]) $flag = !$flag;
    }

    if (!$flag) {
        echo 'YES';
        return;
    }
}

echo 'NO';

<?php
error_reporting(0);
fscanf(STDIN, "%s", $str);
if (strlen($str) > 0) {
    $arr = str_split($str);
    $unique_arr = array_unique($arr);
    $unique_str = implode('', $unique_arr);
    if (preg_match('/helo/', $unique_str)) {
        echo "YES\n";
    } else {
        echo "NO\n";
    }
}

<?php
while(fscanf(STDIN,"%s",$str)){
    $len = strlen($str);
    $key = "hello ";
    $k = 0;
    $a = 0;
    for($i = 0; $i < $len; ++$i){
        if(!$a && $str[$i] == $key[$k]){
                $a = 1;
            }
        elseif($a && $str[$i] == $key[$k+1]){
            ++$k;
            }
        elseif($a && $str[$i] != $key[$k])
            break;
    }
    if($k == 4)
        echo "YES\n";
    else
        echo "NO\n";

}

<?php
while (fscanf(STDIN, "%s", $string)){
    $length = strlen($string);
    $s = 'hello';
    $s_i = 0;
    for ($i = 0; $i < $length; ++$i){
        if ($s[$s_i] == $string[$i]){
            if ($s[$s_i] == 'o'){
                echo "YES\n";
                $s_i = -1;
                break;
            }
            ++$s_i;
        }
    }
    echo $s_i;

    if ($s_i != -1){
        echo "NO\n";
    }
}

<?php
while (fscanf(STDIN, "%s", $string)){
    $length = strlen($string);
    $s = 'hello';
    $s_i = 0;
    for ($i = 0; $i < $length; ++$i){
        if ($s[$s_i] == $string[$i]){
            if ($s[$s_i] == 'o'){
                echo "YES\n";
                $s_i = -1;
                break;
            }
            ++$s_i;
        }
    }
    if ($s_i != 4 && $s_i != -1){
        echo "NO\n";
    }
}

<?php
	$var = implode('',array_unique(str_split(fgets(STDIN))));
	if (substr_count($var, 'helo')) echo 'YES';
	else echo 'NO';

<?php

$_trans = array(
    'e{1,}' => 'e',
    'h{1,}' => 'h',
    'l{2,}' => 'll',
    'o{1,}' => 'o',
);
$str = fgets(STDIN);
foreach ($_trans as $p => $r) {
    $str = preg_replace('/' . $p . '/i', $r, $str);
}
if (strpos($str, 'hello') !== false) {
    $str = 'YES';
} else {
    $str = 'NO';
}
fwrite(STDOUT, $str);


Tomorrow Peter has a Biology exam. He does not like this subject much, but d days ago he learnt that he would have to take this exam. Peter's strict parents made him prepare for the exam immediately, for this purpose he has to study not less than minTimei and not more than maxTimei hours per each i-th day. Moreover, they warned Peter that a day before the exam they would check how he has followed their instructions.So, today is the day when Peter's parents ask him to show the timetable of his preparatory studies. But the boy has counted only the sum of hours sumTime spent him on preparation, and now he wants to know if he can show his parents a timetable sсhedule with d numbers, where each number sсhedulei stands for the time in hours spent by Peter each i-th day on biology studies, and satisfying the limitations imposed by his parents, and at the same time the sum total of all schedulei should equal to sumTime.

The first input line contains two integer numbers d, sumTime (1 ≤ d ≤ 30, 0 ≤ sumTime ≤ 240) — the amount of days, during which Peter studied, and the total amount of hours, spent on preparation. Each of the following d lines contains two integer numbers minTimei, maxTimei (0 ≤ minTimei ≤ maxTimei ≤ 8), separated by a space — minimum and maximum amount of hours that Peter could spent in the i-th day.

In the first line print YES, and in the second line print d numbers (separated by a space), each of the numbers — amount of hours, spent by Peter on preparation in the corresponding day, if he followed his parents' instructions; or print NO in the unique line. If there are many solutions, print any of them.

<?php
list($a, $b) = explode(" ", trim(fgets(STDIN)));
$e = 0;
$f = 0;
$h = array();
$i = array();
$k = array();
$l = array();
for($x = 1; $x <= $a; $x++)
{
    list($c, $d) = explode(" ", trim(fgets(STDIN)));
    $e += $c;
    $f += $d;
    $g = range($c, $d);
    array_push($h, ceil(array_sum($g) / count($g)));
    array_push($l, floor(array_sum($g) / count($g)));
    array_push($i, $c);
    array_push($k, $d);
}
if(($b < $e) || ($b > $f))
{
    print "NO";
}
else
{
    print "YES" . "\n";
    if(array_sum($h) < $b)
    {
        $j = 0;
        for($x = 0; $x < count($h) * 10; $x++)
        {
            if(array_sum($h) < $b)
            {
                $h[$x] = $k[$x];
                $j++;
            }
            elseif(array_sum($h) > $b)
            {
                $h[$j] -= 1;
            }
            else
            {
                print implode(" ", $h);
                break;
            }
        }
    }
    elseif(array_sum($h) > $b)
    {
        $j = 0;
        for($x = 0; $x < count($l) * 10; $x++)
        {
            if(array_sum($l) > $b)
            {
                $l[$x] = $i[$x];
                $j++;
            }
            elseif(array_sum($l) < $b)
            {
                $l[$j] += 1;
            }
            else
            {
                print implode(" ", $l);
                break;
            }
        }
    }
    elseif(array_sum($h) == $b)
    {
        print implode(" ", $h);
    }
}
?>

<?php declare(strict_types=1);

$fp = fopen('php://stdin', 'r');
[$d, $sumTime] = array_filter(explode(' ', fgets($fp)), 'intval');

$totalMinTime = $totalMaxTime = 0;
$times = [];
for ($i = 0; $i < $d; ++$i) {
    [$minTime, $maxTime] = array_filter(explode(' ', fgets($fp)), 'intval');
    $totalMinTime += $minTime;
    $totalMaxTime += $maxTime;
    $times[] = [$minTime, $maxTime];
}
fclose($fp);

if ($totalMinTime <= $sumTime && $sumTime <= $totalMaxTime) {
    echo "YES\n";
    $days = [];
    foreach ($times as [$minTime, $maxTime]) {
        $totalMinTime -= $minTime;
        $totalMaxTime -= $maxTime;

        $min = max($sumTime - $totalMaxTime, 0);
        //$max = $sumTime - $totalMinTime;

        $hours = max($min, $minTime);
        $days[] = $hours;

        $sumTime -= $hours;
    }

    echo join(' ', $days);
} else {
    echo 'NO';
}

<?php

list($d, $sumTime)  = explode(' ', readline());

$days = [];
$minTimeS = 0;
$maxTimeS = 0;

for($i = 0; $i < $d; $i++){

    $days[$i] = explode(' ', readline());
    $minTimeS += $days[$i][0];
    $maxTimeS += $days[$i][1];

}
if($maxTimeS < $sumTime){
    echo 'NO';
    die();
}

if($minTimeS <= $sumTime){
    echo "YES\n";
    foreach ($days as $key => $day){
        if($minTimeS == $sumTime){
            echo $day[0] . ' ';
            continue;
        }else{
            if($minTimeS + ($day[1] - $day[0]) > $sumTime){
                echo ($day[0] + ($sumTime - $minTimeS)) . ' ';
                $minTimeS = $sumTime;
                continue;
            }
            $minTimeS += ($day[1] - $day[0]);
            echo $day[1] . ' ';
        }
    }
}else{
    echo 'NO';
    die();
}

<?php

###### IO ######
error_reporting(E_ALL);
#error_reporting(0);

function readString($f) {
	$r = array(
		"\r" => '',
		"\n" => '',
	);
	return strtr(fgets($f), $r);
}

function readNumString($f) {
	return trim(fgets($f));
}

function stringToArray($str) {
	return str_split($str);
}

function readNum($f, $is_int = false) {
	$v = readNumString($f);
	return $is_int ? intval($v) : floatval($v);
}

function readStringExplode($f, $delimiter = ' ') {
	$v = readNumString($f);
	if ($delimiter == '') {
		$return = stringToArray($v);
	} else {
		$return = explode($delimiter, $v);
	}
	$callf = 'trim';
	return array_map($callf, $return);
}

function readStringExplodeNum($f, $delimiter = ' ', $is_int = false) {
	$v = readNumString($f);
	if ($delimiter == '') {
		$return = stringToArray($v);
	} else {
		$return = explode($delimiter, $v);
	}
	$callf = $is_int ? 'intval' : 'floatval';
	return array_map($callf, $return);
}

###### /IO ######

function getAnswer($is_test = false, $f = false) {
	if ($is_test === false) {
		$f = STDIN;
	}
	/* begin body */
	list($d, $sum) = readStringExplodeNum($f, ' ', true);

	$days = array();
	$canMin = $canMax = array();
	for ($i = 0; $i < $d; $i++) {
		list($canMin[$i], $canMax[$i]) = readStringExplodeNum($f, ' ', true);
		$days[$i] = $canMin[$i];
	}

	$_sum = array_sum($days);
	do {
		$diff = $sum - $_sum;
		if ($diff < 0)
			break;
		$success = false;
		foreach ($days as $i => $cnt) {
			$minMaxDiff = $canMax[$i] - $canMin[$i];
			if ($cnt < $canMax[$i]) {
				$success = true;
				$days[$i]+=min($diff, $minMaxDiff);
				break;
			}
		}
		if (!$success) {
			break;
		}
		$_sum = array_sum($days);
	} while ($_sum < $sum);
	if ($_sum != $sum) {
		echo 'NO';
	} else {
		echo 'YES' . "\r\n";
		echo implode(" ", $days);
	}
	/* / end body */
}

if (empty($is_test))
	getAnswer();

<?php
list($a, $b) = explode(" ", trim(fgets(STDIN)));
$e = 0;
$f = 0;
$h = array();
$i = array();
$k = array();
for($x = 1; $x <= $a; $x++)
{
    list($c, $d) = explode(" ", trim(fgets(STDIN)));
    $e += $c;
    $f += $d;
    $g = range($c, $d);
    array_push($h, ceil(array_sum($g) / count($g)));
    array_push($i, $c);
    array_push($k, $d);
}
if(($b < $e) || ($b > $f))
{
    print "NO";
}
else
{
    print "YES" . "\n";
    if(array_sum($h) < $b)
    {
        $j = 0;
        for($x = 0; $x < count($h) * 10; $x++)
        {
            if(array_sum($h) < $b)
            {
                $h[$x] = $k[$x];
                $j++;
            }
            elseif(array_sum($h) > $b)
            {
                $h[$j] -= $j;
            }
            else
            {
                print implode(" ", $h);
                break;
            }
        }
    }
    elseif(array_sum($h) > $b)
    {
        $j = 0;
        for($x = 0; $x < count($h) * 10; $x++)
        {
            if(array_sum($h) > $b)
            {
                $h[$x] = $i[$x];
                $j++;
            }
            elseif(array_sum($h) < $b)
            {
                $h[$j] += $j;
            }
            else
            {
                print implode(" ", $h);
                break;
            }
        }
    }
    elseif(array_sum($h) == $b)
    {
        print implode(" ", $h);
    }
}
?>

<?php
list($a, $b) = explode(" ", trim(fgets(STDIN)));
$e = array();
$f = array();
$g = array();
$h = array();
for($x = 1; $x <= $a; $x++)
{
    list($c, $d) = explode(" ", trim(fgets(STDIN)));
    array_push($e, $c);
    array_push($f, $d);
}
for($x = 0; $x < $a; $x++)
{
    if($b >= $e[$x])
    {
        array_push($g, $f[$x]);
    }
}
for($x = 0; $x < count($g); $x++)
{
    $b -= $g[$x];
    if($b > 0)
    {
        array_push($h, $g[$x]);
    }
    elseif($b == 0)
    {
        array_push($h, $g[$x]);
        $b = -1;
        break;
    }
    elseif($b < 0)
    {
        array_push($h, $g[$x] + $b);
        break;
    }
}
if($b < 0)
{
    print "YES" . "\n";
}
else
{
    print "NO";
}
if($b < 0)
{
    print implode(" ", $h);
}
?>

<?php
list($a, $b) = explode(" ", trim(fgets(STDIN)));
$e = 0;
$f = 0;
$h = array();
$i = array();
$k = array();
for($x = 1; $x <= $a; $x++)
{
    list($c, $d) = explode(" ", trim(fgets(STDIN)));
    $e += $c;
    $f += $d;
    $g = range($c, $d);
    array_push($h, ceil(array_sum($g) / count($g)));
    array_push($i, $c);
    array_push($k, $d);
}
if(($b < $e) || ($b > $f))
{
    print "NO";
}
else
{
    print "YES" . "\n";
    if(array_sum($h) < $b)
    {
        $j = 0;
        for($x = 0; $x < count($h) * 10; $x++)
        {
            if(array_sum($h) < $b)
            {
                $h[$x] = $k[$x];
                $j++;
            }
            elseif(array_sum($h) > $b)
            {
                $h[$j] -= 1;
            }
            else
            {
                print implode(" ", $h);
                break;
            }
        }
    }
    elseif(array_sum($h) > $b)
    {
        $j = 0;
        for($x = 0; $x < count($h) * 10; $x++)
        {
            if(array_sum($h) > $b)
            {
                $h[$x] = $i[$x];
                $j++;
            }
            elseif(array_sum($h) < $b)
            {
                $h[$j] += 1;
            }
            else
            {
                print implode(" ", $h);
                break;
            }
        }
    }
    elseif(array_sum($h) == $b)
    {
        print implode(" ", $h);
    }
}
?>

<?php

list($d, $sumTime)  = explode(' ', readline());

$days = [];
$minTimeS = 0;
$maxTimeS = 0;

for($i = 0; $i < $d; $i++){

    $days[$i] = explode(' ', readline());
    $minTimeS += $days[$i][0];
    $maxTimeS += $days[$i][1];

}
if($maxTimeS < $sumTime){
    echo 'NO';
    die();
}

if($minTimeS < $sumTime){
    echo "YES \n";
    foreach ($days as $key => $day){
        $minTimeS += ($day[1] - $day[0]);
        if($minTimeS < $sumTime){
            echo $day[0] . ' ';
            continue;
        }else{
            echo $day[1] . ' ';
        }
    }
}else{
    echo "YES \n";
    foreach ($days as $key => $day){
        echo $day[0] . ' ';
    }
}

<?php

list($d, $sumTime)  = explode(' ', readline());

$days = [];
$minTimeS = 0;
$maxTimeS = 0;

for($i = 0; $i < $d; $i++){

    $days[$i] = explode(' ', readline());
    $minTimeS += $days[$i][0];
    $maxTimeS += $days[$i][1];

}
if($maxTimeS < $sumTime){
    echo 'NO';
    die();
}

if($minTimeS <= $sumTime){
    echo "YES\n";
    foreach ($days as $key => $day){
        $minTimeS += ($day[1] - $day[0]);
        if($minTimeS < $sumTime){
            echo $day[0] . ' ';
            continue;
        }else{
            echo $day[1] . ' ';
        }
    }
}else{
    echo 'NO';
    die();
}

<?php

list($d, $sumTime)  = explode(' ', readline());

$days = [];
$minTimeS = 0;
$maxTimeS = 0;

for($i = 0; $i < $d; $i++){

    $days[$i] = explode(' ', readline());
    $minTimeS += $days[$i][0];
    $maxTimeS += $days[$i][1];

}
if($maxTimeS < $sumTime){
    echo 'NO';
    die();
}

if($minTimeS < $sumTime){
    echo "YES\n";
    foreach ($days as $key => $day){
        $minTimeS += ($day[1] - $day[0]);
        if($minTimeS < $sumTime){
            echo $day[0] . ' ';
            continue;
        }else{
            echo $day[1] . ' ';
        }
    }
}else{
    echo "YES\n";
    foreach ($days as $key => $day){
        echo $day[0] . ' ';
    }
}

<?php

###### IO ######
error_reporting(E_ALL);
#error_reporting(0);

function readString($f) {
	$r = array(
		"\r" => '',
		"\n" => '',
	);
	return strtr(fgets($f), $r);
}

function readNumString($f) {
	return trim(fgets($f));
}

function stringToArray($str) {
	return str_split($str);
}

function readNum($f, $is_int = false) {
	$v = readNumString($f);
	return $is_int ? intval($v) : floatval($v);
}

function readStringExplode($f, $delimiter = ' ') {
	$v = readNumString($f);
	if ($delimiter == '') {
		$return = stringToArray($v);
	} else {
		$return = explode($delimiter, $v);
	}
	$callf = 'trim';
	return array_map($callf, $return);
}

function readStringExplodeNum($f, $delimiter = ' ', $is_int = false) {
	$v = readNumString($f);
	if ($delimiter == '') {
		$return = stringToArray($v);
	} else {
		$return = explode($delimiter, $v);
	}
	$callf = $is_int ? 'intval' : 'floatval';
	return array_map($callf, $return);
}

###### /IO ######

function getAnswer($is_test = false, $f = false) {
	if ($is_test === false) {
		$f = STDIN;
	}
	/* begin body */
	list($d, $sum) = readStringExplodeNum($f, ' ', true);

	$days = array();
	$canMin = $canMax = array();
	for ($i = 0; $i < $d; $i++) {
		list($canMin[$i], $canMax[$i]) = readStringExplodeNum($f, ' ', true);
		$days[$i] = $canMin[$i];
	}

	$_sum = array_sum($days);
	do {
		$diff = $sum - $_sum;
		$success = false;
		foreach ($days as $i => $cnt) {
			$minMaxDiff = $canMax[$i] - $canMin[$i];
			if ($cnt < $canMax[$i]) {
				$success = true;
				$days[$i]+=min($diff, $minMaxDiff);
				break;
			}
		}
		if (!$success) {
			break;
		}
		$_sum = array_sum($days);
	} while ($_sum < $sum);
	if ($_sum != $sum) {
		echo 'NO';
	} else {
		echo 'YES' . "\r\n";
		echo implode(" ", $days);
	}
	/* / end body */
}

if (empty($is_test))
	getAnswer();


There was once young lass called Mary,  Whose jokes were occasionally scary.  On this April's Fool  Fixed limerick rules  Allowed her to trip the unwary.Can she fill all the linesTo work at all times?On juggling the wordsRight around two-thirdsShe nearly ran out of rhymes.

The input contains a single integer $$$a$$$ ($$$4 \le a \le 998$$$). Not every integer in the range is a valid input for the problem; you are guaranteed that the input will be a valid integer.

<?php
function solve(){
    $x=readLine();
    $cl;
    for($i=2;$i<=sqrt($x);$i++){
        if($x%$i==0)$cl=$i;
    }
    print $cl. $x/$cl;
}
function main(){
    $t=1;
    //$t=readLine();
    for($i=0;$i<$t;$i++){
        solve();
    }
}
main();
?>

<?php
function solve(){
    $x=readLine();
    $cl;
    for($i=2;$i<=sqrt($x);$i++){
        if($x%$i==0)$cl=$i;
    }
    print $cl. x/$cl;
}
function main(){
    $t=1;
    //$t=readLine();
    for($i=0;$i<$t;$i++){
        solve();
    }
}
main();
?>


Winnie-the-Pooh likes honey very much! That is why he decided to visit his friends. Winnie has got three best friends: Rabbit, Owl and Eeyore, each of them lives in his own house. There are winding paths between each pair of houses. The length of a path between Rabbit's and Owl's houses is a meters, between Rabbit's and Eeyore's house is b meters, between Owl's and Eeyore's house is c meters.For enjoying his life and singing merry songs Winnie-the-Pooh should have a meal n times a day. Now he is in the Rabbit's house and has a meal for the first time. Each time when in the friend's house where Winnie is now the supply of honey is about to end, Winnie leaves that house. If Winnie has not had a meal the required amount of times, he comes out from the house and goes to someone else of his two friends. For this he chooses one of two adjacent paths, arrives to the house on the other end and visits his friend. You may assume that when Winnie is eating in one of his friend's house, the supply of honey in other friend's houses recover (most probably, they go to the supply store).Winnie-the-Pooh does not like physical activity. He wants to have a meal n times, traveling minimum possible distance. Help him to find this distance.

First line contains an integer n (1 ≤ n ≤ 100) — number of visits. Second line contains an integer a (1 ≤ a ≤ 100) — distance between Rabbit's and Owl's houses. Third line contains an integer b (1 ≤ b ≤ 100) — distance between Rabbit's and Eeyore's houses. Fourth line contains an integer c (1 ≤ c ≤ 100) — distance between Owl's and Eeyore's houses.

Output one number — minimum distance in meters Winnie must go through to have a meal n times.

NoteIn the first test case the optimal path for Winnie is the following: first have a meal in Rabbit's house, then in Owl's house, then in Eeyore's house. Thus he will pass the distance 2 + 1 = 3.In the second test case Winnie has a meal in Rabbit's house and that is for him. So he doesn't have to walk anywhere at all.

<?php
$a = trim(fgets(STDIN));
$b = trim(fgets(STDIN));
$c = trim(fgets(STDIN));
$d = trim(fgets(STDIN));
if($a == 1)
{
     print "0";
}
else
{
     $e = min($b, $c);
     $f = min($b, $c, $d);
     $g = ($a - 1) * $f;
     print $e + $g - $f;
}
?>


A magic number is a number formed by concatenation of numbers 1, 14 and 144. We can use each of these numbers any number of times. Therefore 14144, 141414 and 1411 are magic numbers but 1444, 514 and 414 are not.You're given a number. Determine if it is a magic number or not.

The first line of input contains an integer n, (1 ≤ n ≤ 109). This number doesn't contain leading zeros.

Print "YES" if n is a magic number or print "NO" if it's not.

<?php

$line = trim(fgets(STDIN));
$digitLen = strlen($line);
if (0 == $digitLen || $line[0] != 1) {
	echo 'NO';
	return;
}

$count4 = 0;
for ($i = 0; $i < $digitLen; $i++) {
	if ($count4 > 2) {
		echo 'NO';
		return;
	}

	$c = $line[$i];
	if ($c == 1) {
		$count4 = 0;
		continue;
	}

	if ($c == 4) {
		$count4++;
		continue;
	}

	echo 'NO';
	return;
}

echo ($count4 > 2) ? 'NO' : 'YES';

<?php
	$input = trim(fgets(STDIN));
	if (preg_match('/^(1|14|144)+$/',$input)) echo "YES";
	else echo "NO";
	echo "\n";

?>

<?php
	function check($x)
	{
		$n = strlen($x);
		for ($i = 0; $i < $n; ++$i)
		{
			if ($x[$i] == 1) continue;
			if ($x[$i] == 4)
			{
				if ($i > 0 && $x[$i - 1] == 1) continue;
				if ($i - 1 > 0 && $x[$i - 1] == 4 && $x[$i - 2] == 1) continue;
			}
			return false;
		}
		return true;
	}

	$input = trim(fgets(STDIN));
	if (check($input)) echo "YES";
	else echo "NO";
	echo "\n";

?>

<?php
$a=trim(fgets(STDIN));
if(preg_match('/^(14|1|144)+$/',$a))echo "YES";
else echo "NO";
?>

<?php
$input=trim(fgets(STDIN));
settype($input,'string');
$a=0;
$input2=[];
$y=0;$ccy=0;$c=0;
$input2=str_split($input);
for ($i=0;$i<strlen($input); $i++) {

  if($i<strlen($input)-2 and $input2[$i] == 1 and $input2[$i+1] == 4 and $input2[$i+2] == 4 ){
      $ccy+=3;
      $i+=2;
  }else if($i<strlen($input)-1 and $input2[$i] == 1 and $input2[$i+1] == 4){
       $c+=2;
       $i+=1;
  }else if($input2[$i] == 1 ){
       $y++;
  }
}
$k=$ccy + $c+$y  ;
if(count($input2) == $k){
     echo "YES";
}else{
     echo "NO";
}

<?php
$in=explode("\r\n",file_get_contents("php://stdin"))[0];
$in=str_replace('144','.',$in);
$in=str_replace('14','.',$in);
$in=str_replace('1','.',$in);
for($i=0;$i<strlen($in);$i++){
    if($in[$i]!='.'){
        echo("NO\n");
        return false;
    }
}
echo("YES\n");

<?php
$a=trim(fgets(STDIN));
if( preg_match('/^(1|14|144)+$/',$a) ) echo "YES"; else echo "NO";

?>

<?php

error_reporting(-1);

$s = fopen("php://stdin", 'r');
$input = fgets($s);
$input = trim($input);

function valid($string) {
    $a = 1;
    $b = 14;
    $c = 144;
    if ($string == $a || $string == $b || $string == $c)
        return true;
}

$currentSequence = "";
$condition = true;
foreach (str_split($input) as $key => $value) {
    if ($value != "1" && $value != "4")
        $condition = false;

    if (empty($currentSequence) || valid($currentSequence)) {
        $currentSequence = $currentSequence . $value;
    } elseif (strlen($currentSequence) >= 1) {
        $currentSequence = $value;
    } else {
        $condition = false;
    }

    if (!valid($currentSequence)) {
        $currentSequence = $value;
        if (!valid($currentSequence)) {
            $condition = false;
        }
    }
}

echo $condition === true ? "YES\n" : "NO\n";

<?php
// for example, the input is '5 9'
$input = trim(fgets(STDIN));

function magicNumber($input){
	$numbers = str_split($input);
	foreach($numbers as $key => $number){
		if(!in_array($number, [1,4])){
			return false;
		}
		if($number == 4){
			if($key == 0){
				return false;
			}
			if($numbers[$key-1] == 1){
				continue;
			}elseif($numbers[$key-1] == 4){
				if($numbers[$key-2] == 1)
					continue;
				else
					return false;
			}

		}
	}
	return true;
}
if(magicNumber($input)){
	echo "YES";
}else{
	echo "NO";
}

<?php
	function check($x)
	{
		$n = strlen($x) - 1;
		for ($i = 0; $i < $n; ++$i)
		{
			if ($x[$i] == 1) continue;
			if ($x[$i] == 4)
			{
				if ($i > 0 && $x[$i - 1] == 1) continue;
				if ($i - 1 > 0 && $x[$i - 1] == 4 && $x[$i - 2] == 1) continue;
			}
			return false;
		}
		return true;
	}

	$input = fgets(STDIN);
	if (check($input)) echo "YES";
	else echo "NO";
	echo "\n";

?>

<?php
	function check($x)
	{
		$n = count($x);
		for ($i = 0; $i < $n; ++$i)
		{
			if ($x[$i] == 1) continue;
			if ($x[$i] == 4)
			{
				if ($i > 0 && $x[$i - 1] == 1) continue;
				if ($i - 1 > 0 && $x[$i - 1] == 4 && $x[$i] == 1) continue;
			}
			return false;
		}
		return true;
	}

	$input = fgets(STDIN);
	if (check($input)) echo "YES";
	else echo "NO";
	echo "\n";

?>

<?php

		$input = fgets(STDIN);
		$regex = '/^(1|14|144)+$/';
		if (preg_match($regex, $input)) echo "YES";
		else echo "NO";
		echo "\n";

?>

<?php
	function check($x)
	{
		$n = strlen($x);
		for ($i = 0; $i < $n; ++$i)
		{
			if ($x[$i] == 1) continue;
			if ($x[$i] == 4)
			{
				if ($i > 0 && $x[$i - 1] == 1) continue;
				if ($i - 1 > 0 && $x[$i - 1] == 4 && $x[$i - 2] == 1) continue;
			}
			return false;
		}
		return true;
	}

	$input = fgets(STDIN);
	if (check($input)) echo "YES";
	else echo "NO";
	echo "\n";

?>

<?php
	function check($x)
	{
		$n = count($x);
		for ($i = 0; $i < $n; ++$i)
		{
			if ($x[$i] == 1) continue;
			if ($x[$i] == 4)
			{
				if ($i > 0 && $x[$i - 1] == 1) continue;
				if ($i - 1 > 0 && $x[$i - 1] == 4 && $x[$i - 2] == 1) continue;
			}
			return false;
		}
		return true;
	}

	$input = fgets(STDIN);
	if (check($input)) echo "YES";
	else echo "NO";
	echo "\n";

?>

<?php
	function check($x)
	{
		$n = strlen($x);
		for ($i = 0; $i < $n; ++$i)
		{
			if ($x[$i] == 1) continue;
			if ($x[$i] == 4)
			{
				if ($i > 0 && $x[$i - 1] == 1) continue;
				if ($i - 1 > 0 && $x[$i - 1] == 4 && $x[$i - 2] == 1) continue;
			}
			return false;
		}
		return true;
	}

		$input = fgets(STDIN);
		$regex = '/^(1|14|144)+$/';
		if (preg_match($regex, $input)) echo "YES";
		else echo "NO";
		echo "\n";

?>

<?php
$a=trim(fgets(STDIN));
if(preg_match('/^(14|1|144)+$/',$a))echo "YES";
else echo "NO";
echo '<br/>';
?>

<?php
$in=explode("\r\n",file_get_contents("php://stdin"))[0];
$in=str_replace('144','',$in);
$in=str_replace('14','',$in);
$in=str_replace('1','',$in);
if(strlen($in)==0){
    echo("YES\n");
}else{
    echo("NO\n");
}

<?php
// for example, the input is '5 9'
$input = trim(fgets(STDIN));

function magicNumber($input){
	$numbers = str_split($input);
	foreach($numbers as $key => $number){
		if(!in_array($number, [1,4])){
			return false;
		}
		if($number == 4){
			if($numbers[$key-1] == 1){
				continue;
			}elseif($numbers[$key-1] == 4){
				if($numbers[$key-2] == 1)
					continue;
				else
					return false;
			}

		}
	}
	return true;
}
if(magicNumber($input)){
	echo "YES";
}else{
	echo "NO";
}


Apart from having lots of holidays throughout the year, residents of Berland also have whole lucky years. Year is considered lucky if it has no more than 1 non-zero digit in its number. So years 100, 40000, 5 are lucky and 12, 3001 and 12345 are not.You are given current year in Berland. Your task is to find how long will residents of Berland wait till the next lucky year.

The first line contains integer number n (1 ≤ n ≤ 109) — current year in Berland.

Output amount of years from the current year to the next lucky one.

NoteIn the first example next lucky year is 5. In the second one — 300. In the third — 5000.

<?php
$a = trim(fgets(STDIN));
if($a[0] == "9")
{
     $b = strlen($a);
     $c = array_fill(0, $b, 0);
     $d = 1 . implode($c);
     print $d - $a;
}
else
{
     $b = strlen($a) - 1;
     $c = array_fill(0, $b, 0);
     $d = ($a[0] + 1) . implode($c);
     print $d - $a;
}
?>


Today Tavas got his test result as an integer score and he wants to share it with his girlfriend, Nafas.His phone operating system is Tavdroid, and its keyboard doesn't have any digits! He wants to share his score with Nafas via text, so he has no choice but to send this number using words.  He ate coffee mix without water again, so right now he's really messed up and can't think.Your task is to help him by telling him what to type.

The first and only line of input contains an integer s (0 ≤ s ≤ 99), Tavas's score.

In the first and only line of output, print a single string consisting only from English lowercase letters and hyphens ('-'). Do not use spaces.

NoteYou can find all you need to know about English numerals in http://en.wikipedia.org/wiki/English_numerals .

<?php

$number = readline();

$stringNumbers = array(
    1 => 'one',
    2 => 'two',
    3 => 'three',
    4 => 'four',
    5 => 'five',
    6 => 'six',
    7 => 'seven',
    8 => 'eight',
    9 => 'nine',
    10 => 'ten',
    11 => 'eleven',
    12 => 'twelve',
    13 => 'thirteen',
    15 => 'fifteen',
    18 => 'eighteen',
);

$stringFirstNumbers = array(
    1 => '',
    2 => 'twenty',
    3 => 'thirty',
    4 => 'forty',
    5 => 'fifty',
    6 => 'sixty',
    7 => 'seventy',
    8 => 'eighty',
    9 => 'ninety',
);

if ($number <= 13 || $number == 15 || $number == 18)
    echo $number == 0 ? 'zero' : $stringNumbers[$number];

else {
    $firstNumber = $number / 10;
    $secondNumber = $number % 10;

    if ((int)$firstNumber == 1) echo $stringNumbers[(int)$secondNumber].'teen';

    else echo $stringNumbers[(int)$secondNumber] ? $stringFirstNumbers[(int)$firstNumber].'-'.$stringNumbers[(int)$secondNumber] : $stringFirstNumbers[(int)$firstNumber];
}

<?php
// Входящее число: [0 < s < 99]
$s = trim(fgets(STDIN));
// Список числе от 1 до 19, 20, 30, 40, 50, 60, 70, 80, 90
$numbers = array('0' => 'zero', '1' => 'one', '2' => 'two', '3' => 'three', '4' => 'four', '5' => 'five', '6' => 'six', '7' => 'seven', '8' => 'eight', '9' => 'nine', '10' => 'ten', '11' => 'eleven', '12' => 'twelve', '13' => 'thirteen', '14' => 'fourteen', '15' => 'fifteen', '16' => 'sixteen', '17' => 'seventeen', '18' => 'eighteen', '19' => 'nineteen', '20' => 'twenty', '30' => 'thirty', '40' => 'forty', '50' => 'fifty', '60' => 'sixty', '70' => 'seventy', '80' => 'eighty', '90' => 'ninety');
// Если число меньше или равно 19
if ($s <= 19) {
	$result = $numbers[$s];
} else {
	// Проверяем второй символ введенного числа
	if($s[1]==0) {
		// Если 0, то выводим из массива
		$result = $numbers[$s];
	} else {
		// Если нет, то собираем число
		$first_number = $numbers[$s[0].'0'];
		$second_number = $numbers[$s[1]];
		$result = $first_number.'-'.$second_number;
	}
}
print($result);
?>

<?php

$number = readline();

$stringNumbers = array(
    1 => 'one',
    2 => 'two',
    3 => 'three',
    4 => 'four',
    5 => 'five',
    6 => 'six',
    7 => 'seven',
    8 => 'eight',
    9 => 'nine',
    10 => 'ten',
    11 => 'eleven',
    12 => 'twelve',
    13 => 'thirteen',
    15 => 'fifteen'
);

$stringFirstNumbers = array(
    1 => '',
    2 => 'twenty',
    3 => 'thirty',
    4 => 'forty',
    5 => 'fifty',
    6 => 'sixty',
    7 => 'seventy',
    8 => 'eighty',
    9 => 'ninety',
);

if ($number <= 13 || $number == 15)
    echo $number == 0 ? 'zero' : $stringNumbers[$number];

else {
    $firstNumber = $number / 10;
    $secondNumber = $number % 10;

    if ((int)$firstNumber == 1) echo $stringNumbers[(int)$secondNumber].'teen';

    else echo $stringNumbers[(int)$secondNumber] ? $stringFirstNumbers[(int)$firstNumber].'-'.$stringNumbers[(int)$secondNumber] : $stringFirstNumbers[(int)$firstNumber];
}

<?php

$number = readline();

$stringNumbers = array(
    1 => 'one',
    2 => 'two',
    3 => 'three',
    4 => 'four',
    5 => 'five',
    6 => 'six',
    7 => 'seven',
    8 => 'eight',
    9 => 'nine',
    10 => 'ten',
    11 => 'eleven',
    12 => 'twelve',
    13 => 'thirteen',
    15 => 'fifteen'
);

$stringFirstNumbers = array(
    1 => '',
    2 => 'twenty',
    3 => 'thirty',
    4 => 'forty',
    5 => 'fifty',
    6 => 'sixty',
    7 => 'seventy',
    8 => 'eighty',
    9 => 'ninety',
);

if ($number <= 13 || $number === 15)
    echo $number == 0 ? 'zero' : $stringNumbers[$number];

else {
    $firstNumber = $number / 10;
    $secondNumber = $number % 10;

    if ((int)$firstNumber == 1) echo $stringNumbers[(int)$secondNumber].'teen';

    else echo $stringNumbers[(int)$secondNumber] ? $stringFirstNumbers[(int)$firstNumber].'-'.$stringNumbers[(int)$secondNumber] : $stringFirstNumbers[(int)$firstNumber];
}

<?php

$number = readline();

$stringNumbers = array(
    1 => 'one',
    2 => 'two',
    3 => 'three',
    4 => 'four',
    5 => 'five',
    6 => 'six',
    7 => 'seven',
    8 => 'eight',
    9 => 'nine',
    10 => 'ten',
    11 => 'eleven',
    12 => 'twelve',
    13 => 'thirteen',
    15 => 'fifteen'
);

$stringFirstNumbers = array(
    1 => '',
    2 => 'twenty',
    3 => 'thirty',
    4 => 'forty',
    5 => 'fifty',
    6 => 'sixty',
    7 => 'seventy',
    8 => 'eighty',
    9 => 'ninety',
);

if ($number <= 13 || $number === 15)
    echo $number == 0 ? 'zero' : $stringNumbers[$number];

else {
    $firstNumber = $number / 10;
    $secondNumber = $number % 10;

    if ((int)$firstNumber == 1) echo $stringNumbers[(int)$secondNumber].'teen';

    else echo $stringFirstNumbers[(int)$firstNumber].$stringNumbers[(int)$secondNumber];
}

<?php

$number = readline();

$stringNumbers = array(
    1 => 'one',
    2 => 'two',
    3 => 'three',
    4 => 'four',
    5 => 'five',
    6 => 'six',
    7 => 'seven',
    8 => 'eight',
    9 => 'nine',
    10 => 'ten',
    11 => 'eleven',
    12 => 'twelve',
    13 => 'thirteen',
    15 => 'fifteen'
);

$stringFirstNumbers = array(
    1 => '',
    2 => 'twenty',
    3 => 'thirty',
    4 => 'forty',
    5 => 'fifty',
    6 => 'sixty',
    7 => 'seventy',
    8 => 'eighty',
    9 => 'ninety',
);

if ($number <= 13 || $number === 15)
    echo $number == 0 ? 'zero' : $stringNumbers[$number];

else {
    $firstNumber = $number / 10;
    $secondNumber = $number % 10;

    if ((int)$firstNumber == 1) echo $stringNumbers[(int)$secondNumber].'teen';

    else echo $stringFirstNumbers[(int)$firstNumber].'-'.$stringNumbers[(int)$secondNumber];
}

<?php
// Входящее число: [0 < s < 99]
$s = fgets(STDIN);
// Список числе от 1 до 19, 20, 30, 40, 50, 60, 70, 80, 90
$numbers = array('0' => 'zero', '1' => 'one', 2 => 'two', 3 => 'three', 4 => 'four', 5 => 'five', 6 => 'six', 7 => 'seven', '8' => 'eight', 9 => 'nine', 10 => 'ten', 11 => 'eleven', 12 => 'twelve', 13 => 'thirteen', 14 => 'fourteen', 15 => 'fifteen', 16 => 'sixteen', 17 => 'seventeen', 18 => 'eighteen', 19 => 'nineteen', 20 => 'twenty', 30 => 'thirty', 40 => 'forty', 50 => 'fifty', 60 => 'sixty', 70 => 'seventy', 80 => 'eighty', 90 => 'ninety');
// Если число меньше или равно 19
if ($s <= 19) {
	$result = $numbers[$s];
} else {
	// Проверяем второй символ введенного числа
	if($s[1]==0) {
		// Если 0, то выводим из массива
		$result = $numbers[$s];
	} else {
		// Если нет, то собираем число
		$first_number = $numbers[$s[0].'0'];
		$second_number = $numbers[$s[1]];
		$result = $first_number.'-'.$second_number;
	}
}
printf($result);
?>


Little Petya was given this problem for homework:You are given function  (here  represents the operation of taking the remainder). His task is to count the number of integers x in range [a;b] with property f(x) = x.It is a pity that Petya forgot the order in which the remainders should be taken and wrote down only 4 numbers. Each of 24 possible orders of taking the remainder has equal probability of being chosen. For example, if Petya has numbers 1, 2, 3, 4 then he can take remainders in that order or first take remainder modulo 4, then modulo 2, 3, 1. There also are 22 other permutations of these numbers that represent orders in which remainder can be taken. In this problem 4 numbers wrote down by Petya will be pairwise distinct.Now it is impossible for Petya to complete the task given by teacher but just for fun he decided to find the number of integers  with property that probability that f(x) = x is not less than 31.4159265352718281828459045%. In other words, Petya will pick up the number x if there exist at least 7 permutations of numbers p1, p2, p3, p4, for which f(x) = x.

First line of the input will contain 6 integers, separated by spaces: p1, p2, p3, p4, a, b (1 ≤ p1, p2, p3, p4 ≤ 1000, 0 ≤ a ≤ b ≤ 31415).  It is guaranteed that numbers p1, p2, p3, p4 will be pairwise distinct.

Output the number of integers in the given range that have the given property.

<?php
$IN = STDIN;
fscanf($IN, "%d %d %d %d %d %d", $k1, $k2, $k3, $k4, $a, $b);
$min = min(array($k1, $k2, $k3, $k4));
if ($min>$b)
   echo $b-$a+1;
elseif (($min>$a)&&($min<$b))
  echo $min - $a;
else
    echo 0;
?>

<?php
$IN = STDIN;
fscanf($IN, "%d %d %d %d %d %d", $k1, $k2, $k3, $k4, $a, $b);
$min = min(array($k1, $k2, $k3, $k4));
if ($min>$b)
   echo $b-$a;
elseif (($min>$a)&&($min<$b))
  echo $min - $a;
else
    echo 0;
?>


Kolya is very absent-minded. Today his math teacher asked him to solve a simple problem with the equation $$$a + 1 = b$$$ with positive integers $$$a$$$ and $$$b$$$, but Kolya forgot the numbers $$$a$$$ and $$$b$$$. He does, however, remember that the first (leftmost) digit of $$$a$$$ was $$$d_a$$$, and the first (leftmost) digit of $$$b$$$ was $$$d_b$$$.Can you reconstruct any equation $$$a + 1 = b$$$ that satisfies this property? It may be possible that Kolya misremembers the digits, and there is no suitable equation, in which case report so.

The only line contains two space-separated digits $$$d_a$$$ and $$$d_b$$$ ($$$1 \leq d_a, d_b \leq 9$$$).

If there is no equation $$$a + 1 = b$$$ with positive integers $$$a$$$ and $$$b$$$ such that the first digit of $$$a$$$ is $$$d_a$$$, and the first digit of $$$b$$$ is $$$d_b$$$, print a single number $$$-1$$$. Otherwise, print any suitable $$$a$$$ and $$$b$$$ that both are positive and do not exceed $$$10^9$$$. It is guaranteed that if a solution exists, there also exists a solution with both numbers not exceeding $$$10^9$$$.


Capitalization is writing a word with its first letter as a capital letter. Your task is to capitalize the given word.Note, that during capitalization all the letters except the first one remains unchanged.

A single line contains a non-empty word. This word consists of lowercase and uppercase English letters. The length of the word will not exceed 103.

Output the given word after capitalization.

<?php
fscanf(STDIN, '%s\n', $line);

$line = str_split($line, 1); 		// разбиваем строку на массив букв

if($line[0] != ctype_upper($line[0])){
	$line[0] = strtoupper($line[0]);
}

foreach($line as $v){
	printf($v);
}

<?php
fscanf(STDIN, '%s', $s);
echo ucfirst($s);

        <?php
  $fr = fopen("php://stdin", "r");

  fscanf($fr, "%s", $str);

$arr0 = str_split($str);

$arr0[0]=  strtoupper($arr0[0]);

$comma_separated = implode("", $arr0);

echo $comma_separated;

fclose($fr);

?>

<?php

$std = fopen("php://stdin", "r");
fscanf($std, "%s",$str);
echo ucwords($str)."\n";

<?
$a = trim(fgets(STDIN));
$ar = str_split($a);
$x = strtoupper($ar[0]);
for($i=1;$i<count($ar);$i++)
    {
        $x .= $ar[$i];
    }
   echo $x;
?>

<?php
$line = fgets(STDIN);

$line[0] = strtoupper($line[0]);
echo $line;

<?php
//281A: Word Capitalization
$word = trim(fgets(STDIN)); //$word = "ApPLe";
$explode = str_split($word);
$explode[0] = strtoupper($explode[0]);
$implode = implode($explode);
echo $implode;
?>

<?php
	$input = trim(fgets(STDIN));
	echo ucfirst($input);
?>

<?php
fscanf(STDIN,"%s",$s);
$a=strtoupper(substr($s,0,1));
$b=$a.substr($s,1,(strlen($s)-1));
echo $b;

<?php
$a = trim(fgets(STDIN));
$b = str_split($a);
$b[0] = strtoupper($b[0]);
$c = implode($b);
print $c;
?>

<?php
$word = fgets(STDIN);
$word = str_split($word);
if (!ctype_upper($word[0])) {
    $word[0] = strtoupper($word[0]);
}
echo implode($word);
?>

<?php
    $fp = fopen('php://stdin', 'r');
    echo ucfirst(rtrim(fgets($fp)));
?>

<?php
	$in = fgets(STDIN);
	$len = strlen($in);
	echo strtoupper(substr($in,0,1)).substr($in,1,$len-1);

<?php
    $dir = explode(' ',stream_get_contents(fopen("php://stdin", 'r')));
    for($i = 0; $i < count($dir); $i++){
        echo ucfirst($dir[$i]);
    }
?>

<?php
$string = trim(fgets(STDIN));

echo strtoupper(substr($string, 0 , 1)) .substr($string, 1);

<?php
    function islower($c) {
        return ($c >= 'a' && $c <= 'z');
    }

    $s = trim(fgets(STDIN));

    if (islower($s[0])) {
        $char = ord($s[0]) + ord("A") - ord("a");
        $s[0] = chr($char);
    }

    echo $s;
?>

<?php

    $word = fgets(STDIN);
    if(ctype_lower($word[0])){
    	$word = ucfirst($word);
    }
    echo $word;

?>

#!/usr/bin/php
<?php
$s = fopen("php://stdin", 'r');
$word = fgets($s);
echo ucfirst($word);

<?php
$s=trim(fgets(STDIN));
$s[0]=strtoupper($s[0]);
echo $s;
?>

<?php

$s =  str_split(readline());
$s[0] = strtoupper($s[0]);

echo implode('',$s);

<?php
$str = readline();
if($str[0]>='a') $str[0] = chr(ord($str[0]) - 32);
echo $str;

<?php
/**
 * Secdra @2020
 */

$word = trim(fgets(STDIN));
$word[0] = strtoupper($word[0]);
printf("%s", $word);

<?php
$dir= fopen('php://stdin','r');
$filr= file('php://stdin');
$str= trim($filr[0]);
$cap=[];
for ($i=0,$c=strlen($str);$i<$c;$i++){
    if ($i==0){
        $cap[]=strtoupper($str[$i]);
    }else{
        $cap[]=$str[$i];
    }
}
echo implode('',$cap);

<?php

$a = trim(fgets(STDIN));
for($i=1 ; $a[$i] ; $i++)
   $b = $b.$a[$i];

echo strtoupper($a[0]).$b;
?>

<?php
    $n = trim(fgets(STDIN));
    $n[0] = strtoupper($n[0]);
    fwrite(STDOUT, $n);

<?php
while($s = fgets(STDIN)){
    $input .= $s;
}

$input = (string) $input;
$input[0] = strtoupper($input[0]);
echo $input;

<?php
	echo ucfirst(trim(fgets(STDIN)));
?>

<?php

$w =  fgets(STDIN);

$stri = (string)$w;
$n = strlen($stri);

$a = $stri[0];
if(ord($a)>96 && ord($a)<123) {  $stri[0] = chr((ord($a)-32));
		//for($i=0;$i<$n;$i++){echo $stri[$i];}
		}
//echo ord($a);

echo $stri;

<?php
 $arr=fgets(STDIN);

  echo(ucfirst($arr));

 ?>

<?php
// Retrieve input
$stdin = fopen('php://stdin', 'r');
function input()
{
    global $stdin;
    $ashar = explode(" ", trim(fgets($stdin)));
    return $ashar[0];
}

$N = input();
$N[0] = strtoupper($N[0]);
echo $N;
echo "\n";

?>

<?php
	$n = trim(fgets(STDIN));
	$res = ucfirst($n);
	fwrite(STDOUT,"$res");
?>

<?php
$fp = fopen("php://STDIN", "r");
$s = fgets($fp);
$s2 = substr($s, 1);
echo strtoupper($s[0]).$s2;
?>

<?php

function dd(...$args)
{
    var_dump(...$args);
    die;
}

define('TXTIN', fopen('input.txt', 'r'));
define('TXTOUT', fopen('output.txt', 'w'));

//$input = TXTIN;
$input = STDIN;
//$output = TXTOUT;
$output = STDOUT;

function foo($s)
{
    $newS0 = strtoupper($s[0]);
    $s[0] = $newS0;

    return $s;
}

$r = 0;

list($s) = fscanf($input, "%s");

if ($s === null) {
    $r = '';
} else {
    $r = foo($s);
}

fwrite($output, $r);

<?php
$w = trim(fgets(STDIN));
echo ucfirst($w);

<?php
$word = trim(fgets(STDIN));
echo strtoupper($word[0]).substr($word,1);

<?php

function getStdIn(bool $asInt = false): array
{
    $stdIn = explode(' ', trim(fgets(STDIN)));

    if ($asInt) {
        foreach ($stdIn as $key => $value) {
            $stdIn[$key] = (int)$value;
        }
    }

    return $stdIn;
}

function stdOut($output)
{
    fwrite(STDOUT, $output);
}

function solve(): void
{
    [$word] = getStdIn();
    stdOut(ucfirst($word));
}

solve();

<?php

$stdin = fopen('php://stdin','r');
$s = trim(fgets($stdin));
fclose($stdin);

echo ucfirst($s);
?>

<?php
$ip     = fopen('php://stdin', "r");
$op     = fopen('php://stdout',"w");

fwrite($op, sprintf("%s", ucwords(trim(fgets($ip)))));
?>

<?php
$str=trim(fgets(STDIN));
$len=strlen($str);
$rest="";
for($i=1;$i<$len;$i++)
	$rest.=$str[$i];
//$j=json_encode($rest);
echo strtoupper($str[0]).$rest;

<?php

$fi = fopen('php://stdin', 'r');
$a=fgets($fi);
//$address=fgets($fi)*1;
//$time=fgets($fi)*1;
//$address = 'Python';

//$a = 'ApPLe';
echo ucfirst($a);

<?php
$string = trim(fgets(STDIN));
echo ucfirst($string);
?>

<?php
    $f = fopen('php://stdin', 'r');
    //$f = fopen('1q.txt', 'r');
    $s = trim(fgets($f));

    echo strtoupper($s[0]).substr($s,1);

<?php

$stdout = fopen(getenv("OUTPUT_PATH"), "w");
$stdin = fopen("php://stdin", "r");

fscanf($stdin, "%s", $s);

if( ord( $s[0] ) >= 97 )
{
     $s[0] = strtoupper( $s[0] ) ;
}
echo $s ;

fwrite($stdout);

fclose($stdin);
fclose($stdout);

?>

<?php
$word = rtrim(fgets(STDIN));

if(ctype_upper($word[0])){
    echo($word);
}else{
    echo(ucfirst($word));
}

<?php

fscanf(STDIN, "%s\n", $str);

echo ucfirst($str);

?>

<?php

fscanf(STDIN, "%s\n", $str);

$str_chars = str_split($str);

$oldOrd = ord($str_chars[0]);

if ($oldOrd >= 97 && $oldOrd <= 122) {
    $newOrd = ord($str_chars[0]) - 32;
    $str_chars[0] = chr($newOrd);
}

$new_str = implode("", $str_chars);

echo $new_str;

?>

<?php
$s = trim(fgets(STDIN));
print ucfirst($s);
?>

<?php
  $f = fopen('php://stdin', 'r');
  echo strtoupper(fgetc($f)) . fgets($f);
?>

<?php
//input
$s = fopen("php://stdin", 'r');
$x = stream_get_contents($s);

//data

//calc
$x = strtoupper($x[0]).substr($x,1);

//output
$stdout = fopen('php://stdout', 'w');
fputs ($stdout, $x);

?>

<?php

//First Get The Input.
$input = file_get_contents("php://stdin");

$the_word = $input;

$lower = "abcdefghijklmnopqrstuvwxyz";

$upper = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";

//Transfer $upper & $lower Into Array.
$lower = str_split($lower);

$upper = str_split($upper);

//Combine.
$words = array_combine($lower,$upper);

//Transfer The First Letter From The Input.
$the_word[0] = $words[$the_word[0]];

echo $the_word;

?>

<?php
echo ucfirst(trim(fgets(STDIN)));
?>

<?php
// 281A 	    Капитализация слова

$in = fopen("php://stdin", 'r');

$char = fgetc($in);
$char = strtoupper($char);

$line = fgets($in);

echo $char . $line;

?>

<?php
$n =rtrim(fgets(STDIN));
$n[0] = strtoupper($n[0]);

echo $n;

<?php
    fscanf(STDIN, "%s\n",$str1);
    echo ucfirst($str1);
?>

<?php

$string = fgets(STDIN);

$string[0] = strtoupper($string[0]);

echo $string;

<?php
//281A: Word Capitalization
$word = trim(fgets(STDIN)); $word = "ApPLe";
$explode = str_split($word);
$explode[0] = strtoupper($explode[0]);
$implode = implode($explode);
echo $implode;
?>

<?php
fscanf(STDIN,"%s",$s);
$x=substr($s,0,1);
$a=strtoupper(substr($s,0,1));
$b=explode("$x",$s);
$c=$a.implode("",$b);
echo $c;

<?php
	$in = fgets(STDIN);
	$len = strlen($in);
	$flag = true;
	for ($x = 0; $x < $len; $x++) {
		if ($in[$x] >= 'A' && $in[$x] <= 'Z') {
			$flag = false;
			break;
		}
	}
	if ($flag) {
		echo strtoupper(substr($in,0,1)).substr($in,1,$len-1);
	} else echo $in;

<?php

$a = 'aasdDkjKBJk';
for($i=1 ; $a[$i] ; $i++)
   $b = $b.$a[$i];

echo strtoupper($a[0]).$b;

<?php
 $arr=fgets(STDIN);
 $a=strtoupper($arr[0]);
 echo($a . $arr);

 ?>

<?php
$string = $argv[1];
echo ucfirst($string);

<?php
$word = trim(fgets(stdin));
echo strtoupper($word[0]).substr($word,1);

<?php

function getStdIn(bool $asInt = false): array
{
    $stdIn = explode(' ', trim(fgets(STDIN)));

    if ($asInt) {
        foreach ($stdIn as $key => $value) {
            $stdIn[$key] = (int)$value;
        }
    }

    return $stdIn;
}

function stdOut($output)
{
    fwrite(STDOUT, $output);
}

function solve(): void
{
    [$word] = getStdIn(true);
    stdOut(ucfirst($word));
}

solve();

<?php
    sscanf(STDIN, "%s\n",$str1);
    echo ucfirst($str1);

?>


Fox Ciel has a robot on a 2D plane. Initially it is located in (0, 0). Fox Ciel code a command to it. The command was represented by string s. Each character of s is one move operation. There are four move operations at all:  'U': go up, (x, y)  →  (x, y+1);  'D': go down, (x, y)  →  (x, y-1);  'L': go left, (x, y)  →  (x-1, y);  'R': go right, (x, y)  →  (x+1, y). The robot will do the operations in s from left to right, and repeat it infinite times. Help Fox Ciel to determine if after some steps the robot will located in (a, b).

The first line contains two integers a and b, ( - 109 ≤ a, b ≤ 109). The second line contains a string s (1 ≤ |s| ≤ 100, s only contains characters 'U', 'D', 'L', 'R') — the command.

Print "Yes" if the robot will be located at (a, b), and "No" otherwise.

NoteIn the first and second test case, command string is "RU", so the robot will go right, then go up, then right, and then up and so on.The locations of its moves are (0, 0)  →  (1, 0)  →  (1, 1)  →  (2, 1)  →  (2, 2)  →  ...So it can reach (2, 2) but not (1, 2).

<?
$s = fopen("php://stdin", 'r');
$n = stream_get_contents($s);
$dum = explode("\n",$n);

$arr = explode(' ', $dum[0]);
$a = (int) $arr[0];
$b = (int) $arr[1];
$path = $dum[1];

/*$a=-2;
$b=-2;
$path='UURR';*/

$c_posx=0;
$c_posy=0;

$length=strlen($path);
$cur_pos=0;

$min_x=9999999;
$max_x=-10000000;
$min_y=9999999;
$max_y=-10000000;

$i=0;
while($i<$length*2)
{
    if ($cur_pos>=$length) $cur_pos=0;
    $current_word=$path[$cur_pos];

    switch ($current_word)
    {
        case 'U':
        $c_posy=$c_posy+1;
        break;
        case 'D':
        $c_posy=$c_posy-1;
        break;
        case 'L':
        $c_posx=$c_posx-1;
        break;
        case 'R':
        $c_posx=$c_posx+1;
        break;
    }

    if ($i<$length)
    {
        if ($min_x>$c_posx) $min_x=$c_posx;
        if ($min_y>$c_posy) $min_y=$c_posy;

        if ($max_x<$c_posx) $max_x=$c_posx;
        if ($max_y<$c_posy) $max_y=$c_posy;
    }

    $i++;
    if ($i==$length)
    {
        $change_x=$c_posx;
        $change_y=$c_posy;
    }
    if ($i==$length*2)
    {
        $change_x_2=$c_posx;
        $change_y_2=$c_posy;
    }
    $cur_pos++;
}

$plav_x=$max_x-$min_x;
$plav_y=$max_y-$min_y;

if ($plav_x>$plav_y) $plav=$plav_x; else $plav=$plav_y;

$itog_x=$change_x_2-$change_x;
$itog_y=$change_y_2-$change_y;

$num_x_cycles=abs($a)/abs($itog_x);
$num_y_cycles=abs($b)/abs($itog_y);

if ($num_x_cycles>$num_y_cycles) $num_cycles=$num_x_cycles; else $num_cycles=$num_y_cycles;

$go_iterations=ceil($num_cycles)-$plav;

$c_posx=$itog_x*$go_iterations;
$c_posy=$itog_y*$go_iterations;

$i=0;
$cur_pos=0;
while($i<$length*($plav+1))
{
    if ($cur_pos>=$length) $cur_pos=0;
    $current_word=$path[$cur_pos];
    if ($c_posx==$a && $c_posy==$b && $plav==0) die('Yes');

    switch ($current_word)
    {
        case 'U':
        $c_posy=$c_posy+1;
        break;
        case 'D':
        $c_posy=$c_posy-1;
        break;
        case 'L':
        $c_posx=$c_posx-1;
        break;
        case 'R':
        $c_posx=$c_posx+1;
        break;
    }
    //echo $current_word.' '.$c_posx.' '.$c_posy.'
';

    $i++;

    //if (($i % $length) == 0  && $i!=0) echo '
';

    $cur_pos++;
    if ($c_posx==$a && $c_posy==$b) die('Yes');
}
die('No');
?>

<?php
/** chaotic_iak's solution in PHP 5.4 to the problem 321A (Round 190 Div 2 Problem C) in Codeforces **/

/** Module for retrieving input **/

// If this is a local test (a variable declared in a specialized page to open this script), open from localtest.txt instead of php://stdin (because I'm too lazy to supply the arguments by stdin)
if (isset($localtest)) {$stdin = fopen("localtest.txt", "r");} else {$stdin = fopen("php://stdin", "r");}

// A function to retrieve the next line. Takes one optional argument $single, which should be true if the next line (based on problem's specification) has only one number/string/whatever, so I don't have to do silly things like $raw = g(); $num = $raw[0];
function g($single = false) {

	// Take the global $stdin variable aka the file handler so we can access it from this function
	global $stdin;

	// Take the input from the handler, trim it, and explode it based on space (" 1 2 3 " becomes array("1", "2", "3")); trim is usually to remove trailing \r
	$input = explode(" ", trim(fgets($stdin)));

	// If the line is not a single number, return the whole array, otherwise simply return the single string that we exploded for nothing
	if (!$single) {return $input;} else {return $input[0];}
}

/** Imported functions from chaotic_iak's library **/
// none

/** chaotic_iak's solution **/
// This is a competitive programming solution. The code is not remarked (because I want speed).

$raw = g();
$a = $raw[0];
$b = $raw[1];
$s = g(true);
$len = strlen($s);

$xpass = array(0);
$ypass = array(0);
$x = 0;
$y = 0;
for ($i = 0; $i < $len; $i++) {
	switch (substr($s, $i, 1)) {
		case "U":
			$y++;
			break;
		case "R":
			$x++;
			break;
		case "L":
			$x--;
			break;
		case "D":
			$y--;
			break;
	}
	$xpass[] = $x;
	$ypass[] = $y;
}

$xmax = $xpass[$len];
$ymax = $ypass[$len];

for ($i = 0; $i < $len; $i++) {
	$diffx = -1;
	$diffy = -1;
	if ($xmax == 0) {
		if ($xpass[$i] == $a) {$diffx = 1234567890;}
	} else {
		$temp = ($a - $xpass[$i]) % $xmax;
		if (!$temp) {$diffx = ($a - $xpass[$i]) / $xmax;}
	}
	if ($ymax == 0) {
		if ($ypass[$i] == $b) {$diffy = 1234567890;}
	} else {
		$temp = ($b - $ypass[$i]) % $ymax;
		if (!$temp) {$diffy = ($b - $ypass[$i]) / $ymax;}
	}
	if ((($diffx == 1234567890) || ($diffy == 1234567890) || ($diffx == $diffy)) && ($diffx >= 0) && ($diffy >= 0)) {
		echo "Yes"; return 0;
	}
}
echo "No";

<?
$s = fopen("php://stdin", 'r');
$n = stream_get_contents($s);
$dum = explode("\n",$n);

$arr = explode(' ', $dum[0]);
$a = (int) $arr[0];
$b = (int) $arr[1];
$path = $dum[1];

/*$a=4;
$b=3;
$path='UURRDL';*/

$c_posx=0;
$c_posy=0;

$length=strlen($path);
$cur_pos=0;

$i=0;
while($i<$length*2)
{
    if ($cur_pos>=$length) $cur_pos=0;
    $current_word=$path[$cur_pos];

    switch ($current_word)
    {
        case 'U':
        $c_posy=$c_posy+1;
        break;
        case 'D':
        $c_posy=$c_posy-1;
        break;
        case 'L':
        $c_posx=$c_posx-1;
        break;
        case 'R':
        $c_posx=$c_posx+1;
        break;
    }
    $i++;
    if ($i==$length)
    {
        $change_x=$c_posx;
        $change_y=$c_posy;
    }
    if ($i==$length*2)
    {
        $change_x_2=$c_posx;
        $change_y_2=$c_posy;
    }
    $cur_pos++;
}

$itog_x=$change_x_2-$change_x;
$itog_y=$change_y_2-$change_y;

$num_x_cycles=abs($a)/abs($itog_x);
$num_y_cycles=abs($b)/abs($itog_y);

if ($num_x_cycles>$num_y_cycles) $num_cycles=$num_x_cycles; else $num_cycles=$num_y_cycles;

$go_iterations=$num_cycles-2;

$c_posx=$itog_x*$go_iterations;
$c_posy=$itog_y*$go_iterations;

$i=0;
$cur_pos=0;
while($i<$length*3)
{
    if ($cur_pos>=$length) $cur_pos=0;
    $current_word=$path[$cur_pos];

    switch ($current_word)
    {
        case 'U':
        $c_posy=$c_posy+1;
        break;
        case 'D':
        $c_posy=$c_posy-1;
        break;
        case 'L':
        $c_posx=$c_posx-1;
        break;
        case 'R':
        $c_posx=$c_posx+1;
        break;
    }
    $i++;
    $cur_pos++;
    if ($c_posx==$a && $c_posy==$b) die('Yes');
}
die('No');
?>

<?
$s = fopen("php://stdin", 'r');
$n = stream_get_contents($s);
$dum = explode("\n",$n);

$arr = explode(' ', $dum[0]);
$a = (int) $arr[0];
$b = (int) $arr[1];
$path = $dum[1];

/*$a=-1;
$b=-1;
$path='UR';*/

$c_posx=0;
$c_posy=0;

$length=strlen($path);
$cur_pos=0;

$i=0;
while($i<$length*2)
{
    if ($cur_pos>=$length) $cur_pos=0;
    $current_word=$path[$cur_pos];

    switch ($current_word)
    {
        case 'U':
        $c_posy=$c_posy+1;
        break;
        case 'D':
        $c_posy=$c_posy-1;
        break;
        case 'L':
        $c_posx=$c_posx-1;
        break;
        case 'R':
        $c_posx=$c_posx+1;
        break;
    }
    $i++;
    if ($i==$length)
    {
        $change_x=$c_posx;
        $change_y=$c_posy;
    }
    if ($i==$length*2)
    {
        $change_x_2=$c_posx;
        $change_y_2=$c_posy;
    }
    $cur_pos++;
}

$itog_x=$change_x_2-$change_x;
$itog_y=$change_y_2-$change_y;

$num_x_cycles=$a/$itog_x;
$num_y_cycles=$b/$itog_y;

if ($num_x_cycles>$num_y_cycles) $num_cycles=$num_x_cycles; else $num_cycles=$num_y_cycles;

$go_iterations=$num_cycles-2;

$c_posx=$itog_x*abs($go_iterations);
$c_posy=$itog_y*abs($go_iterations);

$i=0;
$cur_pos=0;
while($i<$length*3)
{
    if ($cur_pos>=$length) $cur_pos=0;
    $current_word=$path[$cur_pos];

    switch ($current_word)
    {
        case 'U':
        $c_posy=$c_posy+1;
        break;
        case 'D':
        $c_posy=$c_posy-1;
        break;
        case 'L':
        $c_posx=$c_posx-1;
        break;
        case 'R':
        $c_posx=$c_posx+1;
        break;
    }
    $i++;
    $cur_pos++;
    if ($c_posx==$a && $c_posy==$b) die('Yes');
}
die('No');
?>

<?
$s = fopen("php://stdin", 'r');
$n = stream_get_contents($s);
$dum = explode("\n",$n);

$arr = explode(' ', $dum[0]);
$a = (int) $arr[0];
$b = (int) $arr[1];
$path = $dum[1];

/*$a=2;
$b=2;
$path='RU';*/

$c_posx=0;
$c_posy=0;

$length=strlen($path);
$cur_pos=0;

$i=0;
while($i<$length*2)
{
    if ($cur_pos>=$length) $cur_pos=0;
    $current_word=$path[$cur_pos];

    switch ($current_word)
    {
        case 'U':
        $c_posy=$c_posy+1;
        break;
        case 'D':
        $c_posy=$c_posy-1;
        break;
        case 'L':
        $c_posx=$c_posx-1;
        break;
        case 'R':
        $c_posx=$c_posx+1;
        break;
    }
    $i++;
    if ($i==$length)
    {
        $change_x=$c_posx;
        $change_y=$c_posy;
    }
    if ($i==$length*2)
    {
        $change_x_2=$c_posx;
        $change_y_2=$c_posy;
    }
    $cur_pos++;
}

$itog_x=$change_x_2-$change_x;
$itog_y=$change_y_2-$change_y;

$num_x_cycles=abs($a)/abs($itog_x);
$num_y_cycles=abs($b)/abs($itog_y);

if ($num_x_cycles>$num_y_cycles) $num_cycles=$num_x_cycles; else $num_cycles=$num_y_cycles;

$go_iterations=ceil($num_cycles)-5;

$c_posx=$itog_x*$go_iterations;
$c_posy=$itog_y*$go_iterations;

$i=0;
$cur_pos=0;
while($i<$length*7)
{
    if ($cur_pos>=$length) $cur_pos=0;
    $current_word=$path[$cur_pos];

    switch ($current_word)
    {
        case 'U':
        $c_posy=$c_posy+1;
        break;
        case 'D':
        $c_posy=$c_posy-1;
        break;
        case 'L':
        $c_posx=$c_posx-1;
        break;
        case 'R':
        $c_posx=$c_posx+1;
        break;
    }

    $i++;

    $cur_pos++;
    if ($c_posx==$a && $c_posy==$b) die('Yes');
}
die('No');
?>

<?
$s = fopen("php://stdin", 'r');
$n = stream_get_contents($s);
$dum = explode("\n",$n);

$arr = explode(' ', $dum[0]);
$a = (int) $arr[0];
$b = (int) $arr[1];
$path = $dum[1];

/*$a=-1;
$b=1000000000;
$path='LRRLU';*/

$c_posx=0;
$c_posy=0;

$length=strlen($path);
$cur_pos=0;

$min_x=9999999;
$max_x=-10000000;
$min_y=9999999;
$max_y=-10000000;

$i=0;
while($i<$length*2)
{
    if ($cur_pos>=$length) $cur_pos=0;
    $current_word=$path[$cur_pos];

    switch ($current_word)
    {
        case 'U':
        $c_posy=$c_posy+1;
        break;
        case 'D':
        $c_posy=$c_posy-1;
        break;
        case 'L':
        $c_posx=$c_posx-1;
        break;
        case 'R':
        $c_posx=$c_posx+1;
        break;
    }

    if ($i<$length)
    {
        if ($min_x>$c_posx) $min_x=$c_posx;
        if ($min_y>$c_posy) $min_y=$c_posy;

        if ($max_x<$c_posx) $max_x=$c_posx;
        if ($max_y<$c_posy) $max_y=$c_posy;
    }

    $i++;
    if ($i==$length)
    {
        $change_x=$c_posx;
        $change_y=$c_posy;
    }
    if ($i==$length*2)
    {
        $change_x_2=$c_posx;
        $change_y_2=$c_posy;
    }
    $cur_pos++;
}

$plav_x=$max_x-$min_x;
$plav_y=$max_y-$min_y;

if ($plav_x>$plav_y) $plav=$plav_x; else $plav=$plav_y;

$itog_x=$change_x_2-$change_x;
$itog_y=$change_y_2-$change_y;

$num_x_cycles=abs($a)/abs($itog_x);
$num_y_cycles=abs($b)/abs($itog_y);

if ($num_x_cycles>$num_y_cycles) $num_cycles=$num_x_cycles; else $num_cycles=$num_y_cycles;

$go_iterations=ceil($num_cycles)-$plav;

$c_posx=$itog_x*$go_iterations;
$c_posy=$itog_y*$go_iterations;

$i=0;
$cur_pos=0;
while($i<$length*($plav+1))
{
    if ($cur_pos>=$length) $cur_pos=0;
    $current_word=$path[$cur_pos];
    if ($c_posx==$a && $c_posy==$b) die('Yes');

    switch ($current_word)
    {
        case 'U':
        $c_posy=$c_posy+1;
        break;
        case 'D':
        $c_posy=$c_posy-1;
        break;
        case 'L':
        $c_posx=$c_posx-1;
        break;
        case 'R':
        $c_posx=$c_posx+1;
        break;
    }
    //echo $current_word.' '.$c_posx.' '.$c_posy.'
';

    $i++;

    //if (($i % $length) == 0  && $i!=0) echo '
';

    $cur_pos++;
    if ($c_posx==$a && $c_posy==$b) die('Yes');
}
die('No');
?>

<?
$s = fopen("php://stdin", 'r');
$n = stream_get_contents($s);
$dum = explode("\n",$n);

$arr = explode(' ', $dum[0]);
$a = (int) $arr[0];
$b = (int) $arr[1];
$path = $dum[1];

/*$a=0;
$b=0;
$path='D';*/

$c_posx=0;
$c_posy=0;

$length=strlen($path);
$cur_pos=0;

$max_x=$a-105;
$max_y=$b+105;

$i=0;
while($i<$length*2)
{
    if ($cur_pos>=$length) $cur_pos=0;
    $current_word=$path[$cur_pos];

    if ($c_posx==$a && $c_posy==$b) die('Yes');
    if ($c_posx<$max_x || $c_posx>$max_y || $c_posy>$max_y || $c_posy<$max_x)   die('No');

    switch ($current_word)
    {
        case 'U':
        $c_posy=$c_posy+1;
        break;
        case 'D':
        $c_posy=$c_posy-1;
        break;
        case 'L':
        $c_posx=$c_posx-1;
        break;
        case 'R':
        $c_posx=$c_posx+1;
        break;
    }
    $i++;
    if ($i==$length)
    {
        $change_x=$c_posx;
        $change_y=$c_posy;
    }
    if ($i==$length*2)
    {
        $change_x_2=$c_posx;
        $change_y_2=$c_posy;
    }
    $cur_pos++;
}

$itog_x=$change_x_2-$change_x;
$itog_y=$change_y_2-$change_y;

$num_x_cycles=$a/$itog_x;
$num_y_cycles=$b/$itog_y;

if ($num_x_cycles>$num_y_cycles) $num_cycles=$num_x_cycles; else $num_cycles=$num_y_cycles;

$go_iterations=$num_cycles-1;

$c_posx=$itog_x*$go_iterations;
$c_posy=$itog_y*$go_iterations;

$i=0;
$cur_pos=0;
while($i<$length*2)
{
    if ($cur_pos>=$length) $cur_pos=0;
    $current_word=$path[$cur_pos];

    switch ($current_word)
    {
        case 'U':
        $c_posy=$c_posy+1;
        break;
        case 'D':
        $c_posy=$c_posy-1;
        break;
        case 'L':
        $c_posx=$c_posx-1;
        break;
        case 'R':
        $c_posx=$c_posx+1;
        break;
    }
    $i++;
    $cur_pos++;
    if ($c_posx==$a && $c_posy==$b) die('Yes');
}
die('No');
?>

<?
$s = fopen("php://stdin", 'r');
$n = stream_get_contents($s);
$dum = explode("\n",$n);

$arr = explode(' ', $dum[0]);
$a = (int) $arr[0];
$b = (int) $arr[1];
$path = $dum[1];

/*$a=0;
$b=0;
$path='D';*/

$c_posx=0;
$c_posy=0;

$length=strlen($path);
$cur_pos=0;

$max_x=$a-105;
$max_y=$b+105;

$i=0;
while($i<$length*2)
{
    if ($cur_pos>=$length) $cur_pos=0;
    $current_word=$path[$cur_pos];

    switch ($current_word)
    {
        case 'U':
        $c_posy=$c_posy+1;
        break;
        case 'D':
        $c_posy=$c_posy-1;
        break;
        case 'L':
        $c_posx=$c_posx-1;
        break;
        case 'R':
        $c_posx=$c_posx+1;
        break;
    }
    $i++;
    if ($i==$length)
    {
        $change_x=$c_posx;
        $change_y=$c_posy;
    }
    if ($i==$length*2)
    {
        $change_x_2=$c_posx;
        $change_y_2=$c_posy;
    }
    $cur_pos++;
}

$itog_x=$change_x_2-$change_x;
$itog_y=$change_y_2-$change_y;

$num_x_cycles=$a/$itog_x;
$num_y_cycles=$b/$itog_y;

if ($num_x_cycles>$num_y_cycles) $num_cycles=$num_x_cycles; else $num_cycles=$num_y_cycles;

$go_iterations=$num_cycles-1;

$c_posx=$itog_x*$go_iterations;
$c_posy=$itog_y*$go_iterations;

$i=0;
$cur_pos=0;
while($i<$length*2)
{
    if ($cur_pos>=$length) $cur_pos=0;
    $current_word=$path[$cur_pos];

    switch ($current_word)
    {
        case 'U':
        $c_posy=$c_posy+1;
        break;
        case 'D':
        $c_posy=$c_posy-1;
        break;
        case 'L':
        $c_posx=$c_posx-1;
        break;
        case 'R':
        $c_posx=$c_posx+1;
        break;
    }
    $i++;
    $cur_pos++;
    if ($c_posx==$a && $c_posy==$b) die('Yes');
}
die('No');
?>

<?
$s = fopen("php://stdin", 'r');
$n = stream_get_contents($s);
$dum = explode("\n",$n);

$arr = explode(' ', $dum[0]);
$a = (int) $arr[0];
$b = (int) $arr[1];
$path = $dum[1];

/*$a=4;
$b=3;
$path='UURRDL';*/

$c_posx=0;
$c_posy=0;

$length=strlen($path);
$cur_pos=0;

$max_x=$a-105;
$max_y=$b+105;

$i=0;
while($i<$length*2)
{
    if ($cur_pos>=$length) $cur_pos=0;
    $current_word=$path[$cur_pos];

    switch ($current_word)
    {
        case 'U':
        $c_posy=$c_posy+1;
        break;
        case 'D':
        $c_posy=$c_posy-1;
        break;
        case 'L':
        $c_posx=$c_posx-1;
        break;
        case 'R':
        $c_posx=$c_posx+1;
        break;
    }
    $i++;
    if ($i==$length)
    {
        $change_x=$c_posx;
        $change_y=$c_posy;
    }
    if ($i==$length*2)
    {
        $change_x_2=$c_posx;
        $change_y_2=$c_posy;
    }
    $cur_pos++;
}

$itog_x=$change_x_2-$change_x;
$itog_y=$change_y_2-$change_y;

$num_x_cycles=$a/$itog_x;
$num_y_cycles=$b/$itog_y;

if ($num_x_cycles>$num_y_cycles) $num_cycles=$num_x_cycles; else $num_cycles=$num_y_cycles;

$go_iterations=$num_cycles-2;

$c_posx=$itog_x*$go_iterations;
$c_posy=$itog_y*$go_iterations;

$i=0;
$cur_pos=0;
while($i<$length*3)
{
    if ($cur_pos>=$length) $cur_pos=0;
    $current_word=$path[$cur_pos];

    switch ($current_word)
    {
        case 'U':
        $c_posy=$c_posy+1;
        break;
        case 'D':
        $c_posy=$c_posy-1;
        break;
        case 'L':
        $c_posx=$c_posx-1;
        break;
        case 'R':
        $c_posx=$c_posx+1;
        break;
    }
    $i++;
    $cur_pos++;
    if ($c_posx==$a && $c_posy==$b) die('Yes');
}
die('No');
?>

<?
$s = fopen("php://stdin", 'r');
$n = stream_get_contents($s);
$dum = explode("\n",$n);

$arr = explode(' ', $dum[0]);
$a = (int) $arr[0];
$b = (int) $arr[1];
$path = $dum[1];

/*$a=1000000000;
$b=1000000000;
$path='UURRDL';*/

$c_posx=0;
$c_posy=0;

$length=strlen($path);
$cur_pos=0;

$i=0;
while($i<$length*2)
{
    if ($cur_pos>=$length) $cur_pos=0;
    $current_word=$path[$cur_pos];

    switch ($current_word)
    {
        case 'U':
        $c_posy=$c_posy+1;
        break;
        case 'D':
        $c_posy=$c_posy-1;
        break;
        case 'L':
        $c_posx=$c_posx-1;
        break;
        case 'R':
        $c_posx=$c_posx+1;
        break;
    }
    $i++;
    if ($i==$length)
    {
        $change_x=$c_posx;
        $change_y=$c_posy;
    }
    if ($i==$length*2)
    {
        $change_x_2=$c_posx;
        $change_y_2=$c_posy;
    }
    $cur_pos++;
}

$itog_x=$change_x_2-$change_x;
$itog_y=$change_y_2-$change_y;

$num_x_cycles=$a/$itog_x;
$num_y_cycles=$b/$itog_y;

if ($num_x_cycles>$num_y_cycles) $num_cycles=$num_x_cycles; else $num_cycles=$num_y_cycles;

$go_iterations=$num_cycles-2;
if ($go_iterations<0) $go_iterations=1;

$c_posx=$itog_x*$go_iterations;
$c_posy=$itog_y*$go_iterations;

$i=0;
$cur_pos=0;
while($i<$length*3)
{
    if ($cur_pos>=$length) $cur_pos=0;
    $current_word=$path[$cur_pos];

    switch ($current_word)
    {
        case 'U':
        $c_posy=$c_posy+1;
        break;
        case 'D':
        $c_posy=$c_posy-1;
        break;
        case 'L':
        $c_posx=$c_posx-1;
        break;
        case 'R':
        $c_posx=$c_posx+1;
        break;
    }
    $i++;
    $cur_pos++;
    if ($c_posx==$a && $c_posy==$b) die('Yes');
}
die('No');
?>

<?
$s = fopen("php://stdin", 'r');
$n = stream_get_contents($s);
$dum = explode("\n",$n);

$arr = explode(' ', $dum[0]);
$a = (int) $arr[0];
$b = (int) $arr[1];
$path = $dum[1];

/*$a=2;
$b=6;
$path='RUUUURLDDDL';*/

$c_posx=0;
$c_posy=0;

$length=strlen($path);
$cur_pos=0;

$i=0;
while($i<$length*2)
{
    if ($cur_pos>=$length) $cur_pos=0;
    $current_word=$path[$cur_pos];

    switch ($current_word)
    {
        case 'U':
        $c_posy=$c_posy+1;
        break;
        case 'D':
        $c_posy=$c_posy-1;
        break;
        case 'L':
        $c_posx=$c_posx-1;
        break;
        case 'R':
        $c_posx=$c_posx+1;
        break;
    }
    $i++;
    if ($i==$length)
    {
        $change_x=$c_posx;
        $change_y=$c_posy;
    }
    if ($i==$length*2)
    {
        $change_x_2=$c_posx;
        $change_y_2=$c_posy;
    }
    $cur_pos++;
}

$itog_x=$change_x_2-$change_x;
$itog_y=$change_y_2-$change_y;

$num_x_cycles=abs($a)/abs($itog_x);
$num_y_cycles=abs($b)/abs($itog_y);

if ($num_x_cycles>$num_y_cycles) $num_cycles=$num_x_cycles; else $num_cycles=$num_y_cycles;

$go_iterations=ceil($num_cycles)-5;

$c_posx=$itog_x*$go_iterations;
$c_posy=$itog_y*$go_iterations;

$i=0;
$cur_pos=0;
while($i<$length*3)
{
    if ($cur_pos>=$length) $cur_pos=0;
    $current_word=$path[$cur_pos];

    switch ($current_word)
    {
        case 'U':
        $c_posy=$c_posy+1;
        break;
        case 'D':
        $c_posy=$c_posy-1;
        break;
        case 'L':
        $c_posx=$c_posx-1;
        break;
        case 'R':
        $c_posx=$c_posx+1;
        break;
    }

    $i++;

    $cur_pos++;
    if ($c_posx==$a && $c_posy==$b) die('Yes');
}
die('No');
?>

<?
$s = fopen("php://stdin", 'r');
$n = stream_get_contents($s);
$dum = explode("\n",$n);

$arr = explode(' ', $dum[0]);
$a = (int) $arr[0];
$b = (int) $arr[1];
$path = $dum[1];
/*
$a=2;
$b=2;
$path='RU';*/

$c_posx=0;
$c_posy=0;

$length=strlen($path);
$cur_pos=0;

$min_x=9999999;
$max_x=-10000000;
$min_y=9999999;
$max_y=-10000000;

$i=0;
while($i<$length*2)
{
    if ($cur_pos>=$length) $cur_pos=0;
    $current_word=$path[$cur_pos];

    switch ($current_word)
    {
        case 'U':
        $c_posy=$c_posy+1;
        break;
        case 'D':
        $c_posy=$c_posy-1;
        break;
        case 'L':
        $c_posx=$c_posx-1;
        break;
        case 'R':
        $c_posx=$c_posx+1;
        break;
    }

    if ($i<$length)
    {
        if ($min_x>$c_posx) $min_x=$c_posx;
        if ($min_y>$c_posy) $min_y=$c_posy;

        if ($max_x<$c_posx) $max_x=$c_posx;
        if ($max_y<$c_posy) $max_y=$c_posy;
    }

    $i++;
    if ($i==$length)
    {
        $change_x=$c_posx;
        $change_y=$c_posy;
    }
    if ($i==$length*2)
    {
        $change_x_2=$c_posx;
        $change_y_2=$c_posy;
    }
    $cur_pos++;
}

$plav_x=$max_x-$min_x;
$plav_y=$max_y-$min_y;

if ($plav_x>$plav_y) $plav=$plav_x; else $plav=$plav_y;

$itog_x=$change_x_2-$change_x;
$itog_y=$change_y_2-$change_y;

$num_x_cycles=abs($a)/abs($itog_x);
$num_y_cycles=abs($b)/abs($itog_y);

if ($num_x_cycles>$num_y_cycles) $num_cycles=$num_x_cycles; else $num_cycles=$num_y_cycles;

$go_iterations=ceil($num_cycles)-$plav;

$c_posx=$itog_x*$go_iterations;
$c_posy=$itog_y*$go_iterations;

//echo $num_cycles.' '.$itog_x.' '.$itog_y.'
';

$i=0;
$cur_pos=0;
while($i<$length*($plav+1))
{
    if ($cur_pos>=$length) $cur_pos=0;
    $current_word=$path[$cur_pos];

    switch ($current_word)
    {
        case 'U':
        $c_posy=$c_posy+1;
        break;
        case 'D':
        $c_posy=$c_posy-1;
        break;
        case 'L':
        $c_posx=$c_posx-1;
        break;
        case 'R':
        $c_posx=$c_posx+1;
        break;
    }
    //echo $current_word.' '.$c_posx.' '.$c_posy.'
';

    $i++;

    //if (($i % $length) == 0  && $i!=0) echo '
';

    $cur_pos++;
    if ($c_posx==$a && $c_posy==$b) die('Yes');
}
die('No');
?>

<?
$s = fopen("php://stdin", 'r');
$n = stream_get_contents($s);
$dum = explode("\n",$n);

$arr = explode(' ', $dum[0]);
$a = (int) $arr[0];
$b = (int) $arr[1];
$path = $dum[1];
/*
$a=-261597957;
$b=418556728;
$path='LLLDLUDUULLRDDULLRRUDRDLULRLRLLRRUUDRRLRUDLRRLUDRDLLUUDUULRURLDLULUUULDDUURLRUDURRL';*/

$c_posx=0;
$c_posy=0;

$length=strlen($path);
$cur_pos=0;

$i=0;
while($i<$length*2)
{
    if ($cur_pos>=$length) $cur_pos=0;
    $current_word=$path[$cur_pos];

    switch ($current_word)
    {
        case 'U':
        $c_posy=$c_posy+1;
        break;
        case 'D':
        $c_posy=$c_posy-1;
        break;
        case 'L':
        $c_posx=$c_posx-1;
        break;
        case 'R':
        $c_posx=$c_posx+1;
        break;
    }
    $i++;
    if ($i==$length)
    {
        $change_x=$c_posx;
        $change_y=$c_posy;
    }
    if ($i==$length*2)
    {
        $change_x_2=$c_posx;
        $change_y_2=$c_posy;
    }
    $cur_pos++;
}

$itog_x=$change_x_2-$change_x;
$itog_y=$change_y_2-$change_y;

$num_x_cycles=abs($a)/abs($itog_x);
$num_y_cycles=abs($b)/abs($itog_y);

if ($num_x_cycles>$num_y_cycles) $num_cycles=$num_x_cycles; else $num_cycles=$num_y_cycles;

$go_iterations=ceil($num_cycles)-2;

$c_posx=$itog_x*$go_iterations;
$c_posy=$itog_y*$go_iterations;

$i=0;
$cur_pos=0;
while($i<$length*3)
{
    if ($cur_pos>=$length) $cur_pos=0;
    $current_word=$path[$cur_pos];

    switch ($current_word)
    {
        case 'U':
        $c_posy=$c_posy+1;
        break;
        case 'D':
        $c_posy=$c_posy-1;
        break;
        case 'L':
        $c_posx=$c_posx-1;
        break;
        case 'R':
        $c_posx=$c_posx+1;
        break;
    }
    $i++;
    $cur_pos++;
    if ($c_posx==$a && $c_posy==$b) die('Yes');
}
die('No');
?>


Vova, the Ultimate Thule new shaman, wants to build a pipeline. As there are exactly n houses in Ultimate Thule, Vova wants the city to have exactly n pipes, each such pipe should be connected to the water supply. A pipe can be connected to the water supply if there's water flowing out of it. Initially Vova has only one pipe with flowing water. Besides, Vova has several splitters.A splitter is a construction that consists of one input (it can be connected to a water pipe) and x output pipes. When a splitter is connected to a water pipe, water flows from each output pipe. You can assume that the output pipes are ordinary pipes. For example, you can connect water supply to such pipe if there's water flowing out from it. At most one splitter can be connected to any water pipe.  The figure shows a 4-output splitter Vova has one splitter of each kind: with 2, 3, 4, ..., k outputs. Help Vova use the minimum number of splitters to build the required pipeline or otherwise state that it's impossible.Vova needs the pipeline to have exactly n pipes with flowing out water. Note that some of those pipes can be the output pipes of the splitters.

The first line contains two space-separated integers n and k (1 ≤ n ≤ 1018, 2 ≤ k ≤ 109). Please, do not use the %lld specifier to read or write 64-bit integers in С++. It is preferred to use the cin, cout streams or the %I64d specifier.

Print a single integer — the minimum number of splitters needed to build the pipeline. If it is impossible to build a pipeline with the given splitters, print -1.

<?php
// Retrieve input
$stdin = fopen('php://stdin', 'r');
function g() {
	global $stdin;
	return explode(" ", trim(fgets($stdin)));
}

// Codeforces Contest 176 Div 2 Problem B
$raw = g();
$n = bcsub($raw[0], 1);
$k = bcsub($raw[1], 1);

$c = bcsub(bcmul($k,$k+1), bcmul(2,$n));
if (bccomp(0, $c) == 1) {echo "-1"; exit;}

$sqrt = bcsqrt(bcmul(4,$c), 10);
$raw = explode(".", $sqrt);
$trunc = $raw[0];

if (bcmod($trunc, 2) == 0) {$trunc = bcsub($trunc, 1);}

$m = bcdiv(bcadd($trunc, 1), 2);

if (bcadd(bcmul(4,$c),1) == bcpow(bcadd(bcmul(2,$m),1),2)) {echo bcsub($k, $m);} else {echo bcsub(bcadd($k,1), $m);}

// End of submission file
// Submission by chaotic_iak
?>

<?php
// Retrieve input
$stdin = fopen('php://stdin', 'r');
function g() {
	global $stdin;
	return explode(" ", trim(fgets($stdin)));
}

// Codeforces Contest 176 Div 2 Problem B
$raw = g();
$n = $raw[0] - 1;
$k = $raw[1] - 1;

$c = bcsub(bcmul($k,$k+1), bcmul(2,$n));
if (bccomp(0, $c) == 1) {echo "-1"; exit;}
if (bccomp(0, $c) == 0) {echo $k; exit;}

$min = -1;
$max = bcsub(bcpow(2,30), 1);

while ( (!((bccomp(0, t()) == -1) && (bccomp(t(), bcmul(2,m())) != 1)))
	&& (bccomp(bcsub($max, $min), 1) == 1)) {
	if (bccomp(0, t()) == -1) {
		$min = m();
	} else {
		$max = m();
	}
}

if (bccomp($c, bcmul(m(), bcadd(m(), 1))) == 0) {echo bcsub($k, m());} else {echo bcsub(bcadd($k,1), m());}

function t() {
	global $c, $min, $max;
	$m = m();
	return bcsub($c, bcmul($m, $m-1));
}

function m() {
	global $min, $max;
	return bcdiv(bcadd($min, $max), 2, 0);
}

// End of submission file
// Submission by chaotic_iak
?>

<?php
// Retrieve input
$stdin = fopen('php://stdin', 'r');
function g() {
	global $stdin;
	return explode(" ", trim(fgets($stdin)));
}

// Codeforces Contest 176 Div 2 Problem B
$raw = g();
$n = $raw[0] - 1;
$k = $raw[1] - 1;

$c = bcsub(bcmul($k,$k+1), bcmul(2,$n));
if (bccomp(0, $c) == 1) {echo "-1"; exit;}

$sqrt = bcsqrt(bcmul(4,$c), 10);
$raw = explode(".", $sqrt);
$trunc = $raw[0];

if (bcmod($trunc, 2) == 0) {$trunc = bcsub($trunc, 1);}

$m = bcdiv(bcadd($trunc, 1), 2);

if (bcadd(bcmul(4,$c),1) == bcpow(bcadd(bcmul(2,$m),1),2)) {echo bcsub($k, $m);} else {echo bcsub(bcadd($k,1), $m);}

// End of submission file
// Submission by chaotic_iak
?>