let rec read a b ab o =
  try let btype = Scanf.scanf "%d,%s\n" (fun x y-> y) in
      match btype with
        "A" -> read (a+1) b ab o
        | "B" -> read a (b+1) ab o
        | "AB" -> read a b (ab+1) o
        | "O" -> read a b ab (o+1)
        | _ -> ()
  with
    End_of_file -> Printf.printf "%d\n%d\n%d\n%d\n" a b ab o
in read 0 0 0 0;;