#include using namespace std; using namespace atcoder; int op(int l,int r){return min(l,r);} int e(){return 4;} int main(){ int n; string s; cin >> n >> s; int ans = n; array,3> tb; array b={0,1,2}; auto f=[&](char c){ if(c == 'R')return 0; if(c == 'G')return 1; if(c == 'B')return 2; }; for(int i = 0; i < n; i++) tb[f(s[i])].push_back(i); do{ segtree seg(n); dsu uf(n); for(int i = 0; i < 3; i++){ for(auto j:tb[i])seg.set(j, b[i]); } for(int i = 0; i < 3; i++){ for(int j = 0; j + 1 < tb[i].size(); j++){ if(seg.prod(tb[i][j], tb[i][j+1]) >= b[i])uf.merge(tb[i][j], tb[i][j+1]); } } ans = min(ans, int(uf.groups().size())); }while(next_permutation(b.begin(), b.end())); cout << ans << endl; }