import strutils

let
  s, t = readLine stdin
var
  ans = [0, 0, 0, 0]  # a b ab o

for x in s:
  for y in t:
    let
      set = {x, y}
    if set == {'O'}:
      ans[3].inc 25
    elif set == {'A', 'B'}:
      ans[2].inc 25
    elif 'A' in set:
      ans[0].inc 25
    else:
      ans[1].inc 25

echo ans.join " "