#include<bits/stdc++.h>
using namespace std;
string s;
int main(){
int n;
cin >> n;
getchar();
getline(cin,s);
long long now = 0,ans = 0;
for (int i = 0; i < s.size(); i++){
if (s[i] == 'W'){
ans += abs(0 - now);
// cout << "i=" << i << ':' << abs(0 - now) << '\n';
now = 0;
}
if (s[i] == 'B'){
ans += abs(1 - now);
// cout << "i=" << i << ':' << abs(1 - now) << '\n';
now = 1;
}
if (s[i] == 'R'){
ans += abs(2 - now);
// cout << "i=" << i << ':' << abs(2 - now) << '\n';
now = 2;
}
}
cout << ans;
return 0;
}