program pinochle;
{Branimir Mihaljevic
XV.gimnazija
international
seniors division
contest #2
}
var a,c:char;
b:array[1..4,1..5]of integer;
s:array[1..5]of
integer;
i,j,br,h,k:integer;
t1,t2:boolean;
begin
for i:=1 to 5 do
begin
br:=1;
s[i]:=0;
for j:=1 to 4 do
for h:=1 to 5 do
b[j,h]:=0;
read(a);read(c);
for j:=1 to 19 do
begin
if j=19 then
readln(c)
else
read(c);
case c of
',':br:=br+1;
'A':b[br,1]:=b[br,1]+1;
'K':b[br,2]:=b[br,2]+1;
'Q':b[br,3]:=b[br,3]+1;
'J':b[br,4]:=b[br,4]+1;
'T':b[br,5]:=b[br,5]+1;
end
end;
case a of
'D':h:=1;
'C':h:=2;
'S':h:=3;
'H':h:=4;
end;
t1:=true;t2:=true;
if (b[h,1]>0)
and (b[h,2]>0) and (b[h,3]>0) and (b[h,4]>0) and (b[h,5]>0) then
if (b[h,1]>1)
and (b[h,2]>1) and (b[h,3]>1) and (b[h,4]>1) and (b[h,5]>1) then
begin
s[i]:=s[i]+180;
t2:=false
end
else
begin
s[i]:=s[i]+15;
t1:=false
end;
if (b[1,4]>=1)
and (b[3,3]>=1) then if (b[1,4]=2) and (b[3,3]=2) then s[i]:=s[i]+38
else s[i]:=s[i]+4;
if (b[1,1]>=1)
and (b[2,1]>=1) and (b[3,1]>=1) and (b[4,1]>=1) then
if (b[1,1]=2) and
(b[2,1]=2) and (b[3,1]=2) and (b[4,1]=2) then s[i]:=s[i]+120
else
s[i]:=s[i]+10;
if (b[1,2]>=1)
and (b[2,2]>=1) and (b[3,2]>=1) and (b[4,2]>=1) then
if (b[1,2]=2) and
(b[2,2]=2) and (b[3,2]=2) and (b[4,2]=2) then s[i]:=s[i]+96
else s[i]:=s[i]+8;
if t2 then
if t1 then BEGIN
if (b[h,2]>=1) and (b[h,3]>=1) then if (b[h,2]=2) and (b[h,3]=2) then
s[i]:=s[i]+8
else s[i]:=s[i]+4 END
else if
(b[h,2]=2) and (b[h,3]=2) then s[i]:=s[i]+4;
for k:=1 to 4 do
IF K<>H THEN
begin
if (b[K,2]>=1)
and (b[K,3]>=1) then if (b[K,2]=2) and (b[K,3]=2) then s[i]:=s[i]+4
else s[i]:=s[i]+2;
end;
if (b[1,3]>=1)
and (b[2,3]>=1) and (b[3,3]>=1) and (b[4,3]>=1) then
if (b[1,3]=2) and
(b[2,3]=2) and (b[3,3]=2) and (b[4,3]=2) then s[i]:=s[i]+72
else s[i]:=s[i]+6;
if (b[1,4]>=1)
and (b[2,4]>=1) and (b[3,4]>=1) and (b[4,4]>=1) then
if (b[1,4]=2) and
(b[2,4]=2) and (b[3,4]=2) and (b[4,4]=2) then s[i]:=s[i]+48
else s[i]:=s[i]+4;
end;
for i:=1 to 5 do writeln(s[i]);
end.