<?php while($line = fgets(STDIN)){ $tmp[] = trim($line); } foreach($tmp as $val){ $arr[] = explode(" ", $val); } $stringA = str_split($arr[0][0]); $stringB = str_split($arr[1][0]); $stringCount = count($stringA); $bool = false; for($i=0; $i<$stringCount; $i++){ if(!in_array($stringA[$i], $stringB)){ $bool = false; break; }else{ $bool = true; } } if($bool){ echo "YES"; }else{ echo "NO"; } ?>