#include using namespace std; #ifdef LOCAL #include "settings/debug.cpp" #else #define Debug(...) void(0) #endif #define rep(i, n) for (int i = 0; i < (n); ++i) using ll = long long; using ull = unsigned long long; int main() { int n; string s; cin >> n >> s; int ans = 0; rep(i, n - 1) { if (s.substr(i, 2) == "AA") ++ans; } rep(i, n) { if (s[i] == 'A' && ((i - 1 >= 0 && s[i - 1] == 'B') || (i + 1 < n && s[i + 1] == 'B'))) ++ans; } if (s.contains("BB")) ++ans; cout << ans << endl; return 0; }