1){ if(substr_count($input, "3") == strlen($input)-1 && substr($input, 0, 1) == "1") { $ans= substr_count($input,"3",1); } } echo $ans;