program vig(input,output,infile);

const
  maxlength = 20;

type
  nodepoint = ^nodetype;
  nodetype  = record
                next:nodepoint;
                ch  :char;
              end;
  strarraytype  = packed array[0..maxlength] of char;
  matcharraytype= array[1..maxlength] of integer;

var
  firstptr      :nodepoint;
  currentptr    :nodepoint;
  count         :integer;
  infile        :text;
  strarray      :strarraytype;
  matcharray    :matcharraytype;
  eofstatus     :boolean;
  filesize      :real;

procedure makesmall(chin:char;var chout:char);
begin
  if chin in ['A'..'Z'] then 
  chout:= chr( ord(chin) - ord('A') + ord('a'))
  else
    chout:=chin;
end;

procedure makestring(fptr:nodepoint;var str:strarraytype);
var
  count :integer;
begin
  for count:= 0 to maxlength do
  begin
    str[ count ] := fptr^.ch;
    fptr:=fptr^.next;  
  end;
end;

procedure countmatches(str      :strarraytype;
                       matchin  :matcharraytype;
                       var match:matcharraytype);
var
  count   :integer;
begin
  for count:=1 to maxlength do
  begin
    if str[0] = str[ count ] then
    match[ count]:=matchin[ count] + 1
    else
      match[ count]:=matchin[ count];
  end;
end;
  
begin
  for count:=1 to maxlength do matcharray[ count]:= 0;
  
  reset(infile);
  new(firstptr);
  currentptr:=firstptr;
  count:=0;
  while count <= maxlength do
  begin
    read(infile,currentptr^.ch);
    makesmall(currentptr^.ch,currentptr^.ch);
    if currentptr^.ch in ['a'..'z'] then
    begin
      new(currentptr^.next);
      currentptr:=currentptr^.next;
      count:=count + 1;
    end;
  end;
  makestring(firstptr,strarray);
  countmatches(strarray,matcharray,matcharray);
  eofstatus:=false;
  filesize:=0;
  count:=1;
  while count <= maxlength do
  begin
    read(infile,currentptr^.ch);
    makesmall(currentptr^.ch,currentptr^.ch);
    if currentptr^.ch in [ 'a'..'z'] then
    begin
      firstptr:=firstptr^.next;
      makestring(firstptr,strarray);
      countmatches(strarray,matcharray,matcharray);
      new(currentptr^.next);
      currentptr:=currentptr^.next;
      filesize:=filesize + 1;
      if eofstatus= true then count:=count+1;
    end;
    if eof(infile)=true then
    begin
      reset(infile);
      eofstatus:= true;
    end;
  end;

  writeln('  Shift|%match');
  for count:=1 to maxlength do
    writeln(count:8,' |',((matcharray[count]/filesize)*100):7:3);
end.


