Procedure shifrovka(var S:string);
var
i,j,k:Integer;
M:Set of Byte;
Ch:Char;
begin
M:=[];
for i:= 1 to Length(S) do
begin
If Not(i in M) then
begin
Ch:=S[i];
j:=0;
repeat
Inc(j);
until (str1[j]=Ch) or (j=Length(str1));
If str1[j]=Ch then
for k:=i to Length(S) do
if (S[k]=Ch) and Not(k in M) then
begin
S[k]:=alpha[j];
M:=M+[k];
end;
end;
end;
Writeln(S);
end;
объясните пожалуйста эту часть пошагово