## 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 = 0 array = [] prev = False has_first = 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: has_first = True prev = False if has_first: answer += 1 new_array = [] for ar in array: prev = False has_second = False for j in ar: if S[j] != p[1]: if len(new_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: has_second = True prev = False if has_second: answer += 1 answer += len(new_array) min_answer = min(min_answer, answer) print(min_answer) if __name__ == "__main__": main()