Perhaps it could have been done better, but I studied C++, not Pascal.
var
str1:String;
a,b,c,d,e:Integer;
begin
Write('Enter a string: ');
ReadLn(str1);
a:=pos('ш',str1);
b:=pos('и',str1);
c:=pos('н',str1);
d:=pos('а',str1);
e:=pos('!',str1);
if (a < e) and (b < e) and (c < e) and (d < e) then
Write('Hooray! The word will be formed')
else
Write ('It won't work');
ReadLn;
end.
I assume the first problem has already been solved?