let n = read_line () |> int_of_string in
let s = read_line () in
let rec loop i acc =
    if i < 0 then acc else
        let acc = if s.[i] = 'A' && s.[i + 1] = 'B' && s.[i + 2] = 'C' then acc + 1 else acc in
        loop (i - 1) acc
in
loop (String.length s - 3) 0 |> Printf.printf "%d\n"