## https://yukicoder.me/problems/no/1924 import itertools def main(): N = int(input()) S = input() min_answer = float("inf") for p in itertools.permutations(["R", "G", "B"]): # 一番最初は全部を同じ色で塗りつぶす answer = 1 array = [] prev = False for i in range(N): if S[i] != p[0]: if len(array) == 0: array.append([i]) prev = True else: if not prev: array.append([i]) prev = True else: array[-1].append(i) else: prev = False answer += len(array) new_array = [] for ar in array: prev = False for j in ar: if S[j] != p[1]: if len(array) == 0: new_array.append([j]) prev = True else: if not prev: new_array.append([j]) prev = True else: new_array[-1].append(j) else: prev = False answer += len(new_array) min_answer = min(min_answer, answer) print(min_answer) if __name__ == "__main__": main()