Help me in solving LARGESUB problem

My issue

how they ask about and how “aa” be a good subsequence in my WA on tc 2

My code

#include <bits/stdc++.h>
using namespace std;

int main() {
    int tc;
    cin >> tc;
    while (tc--) {
        int n, cntA = 0, cntB = 0;
        cin >> n;
        string s;
        cin >> s;
        for (int i = 0; i < n; i++) {
            if (s.substr(i, 2) == "ab") {
                cntA++;
                i++;
            } else if (s.substr(i, 2) == "ba") {
                cntB++;
                i++;
            }
        }
        if (n>2) {
            int cnt = cntA + cntB;
            if (n % 2) cout << cnt * 2 + 1 << endl;
            else cout << cnt * 2 << endl;
        } 
        else cout << 1 << endl;
    }
    return 0;
}

Problem Link: Largest Subsequence Practice Coding Problem