func_code_string: #include <bits/stdc++.h>   using namespace std;   using namespace std;   int main() {     int t;     cin >> t;     while (t--) {       int n;       cin >> n;       string s;       cin >> s;       int flag = 1;       int st;       char c = s[0];       for (int i = 1; i < n; i++) {         if (s[i] == c)           continue;         else {           st = i;           flag = 0;           break;         }       }       if (flag == 1) {         cout << (n + 2) / 3 << endl;         continue;       }       int ans = 0;       int m = 1;       c = s[st];       int val = (st + 1) % n;       for (int i = val; i != st; i = ((i + 1) % n)) {         if (s[i] == c) {           m++;         } else {           if (m >= 3) ans += (m) / 3;           c = s[i];           m = 1;         }       }       if (m >= 3) ans += (m / 3);       cout << ans << endl;     }     return 0;   }   