import java.io.PrintWriter; import java.util.Arrays; import java.util.Random; import java.util.Scanner; import java.util.Stack; public class Main implements Runnable { //Runnableを実装する public static void main(String[] args) { new Thread(null, new Main(), "", 16 * 1024 * 1024).start(); //16MBスタックを確保して実行 } void verify() { Random rnd=new Random(); int N=10; int[] a=new int[N]; do { for (int i=0;i stk=new Stack<>(); int ans=0; for (int i=0, j=0; i= 2) { int x=stk.pop(); if (x != stk.peek()) stk.add(x); } if (stk.size() >= 3) { int x=stk.pop(); int y=stk.pop(); int z=stk.pop(); if (x==z) { ans+=1; stk.add(x); continue; } stk.add(z); stk.add(y); stk.add(x); } } ans+=stk.size() - (stk.size() - 1)/ 3; return ans; } public void run() { Scanner sc=new Scanner(System.in); PrintWriter pw=new PrintWriter(System.out); int N=sc.nextInt(); char[] cs=sc.next().toCharArray(); int[] a=new int[N]; Arrays.setAll(a, i->"RGB".indexOf(cs[i])); pw.println(solve(a)); pw.close(); } void tr(Object ... o) {System.out.println(Arrays.deepToString(o));} }