let () =
  Scanf.scanf "%d\n%s\n" @@ fun n s ->
  let ans = ref 0 in
  let checkStr = ref 'A' in
  for i = 0 to n - 1 do
    if s.[i] = 'A' then checkStr := 'B'
    else if s.[i] = 'B' && !checkStr = 'B' then checkStr := 'C'
    else if s.[i] = 'C' && !checkStr = 'C' then (checkStr := 'A'; ans:= !ans + 1)
    else checkStr := 'A'
  done;
  Printf.printf "%d\n" !ans