#include using namespace std; int n, m = 1; string s; bool f; int main() { cin >> n >> s; for (int i = 1; i < n - 1; i++) { if (s[i - 1] == 'A' || s[i + 1] == 'A') { if (s[i] == 'B' && s[i + 1] == 'B') { if (!f) { m++; f = 1; } } else m++; } } cout << m << endl; }