it is easy to find files according to times you prefer.but for getting the result of that you could use awk like this:
awk -F\| '!/^\s*$/{if($4=="S:0"){Arr0[$1","$2","$3]+=1} else {Arr1[$1","$2","$3]+=1}}END{for(i in Arr1){print i,",",Arr0[i],",",Arr1[i]}}'
for explanation:
-F|: define
|as field seperator!/^\s*$/: skip empty lines
if(Clause){Statement}else{statement}: clearEND{...}: this block executes when operator riched to EOF