func_code_string: #include <bits/stdc++.h>   using namespace std;   int get_index(int i, int j, int k) { return i * 4 + j * 2 + k; }   int diff(int i, int j) { return i != j; }   pair<int, string> input() {     int n;     cin >> n;     string s;     cin >> s;     return make_pair(n, s);   }   int work2(int n, string s) {     int first_diff = 1;     for (; first_diff < n; first_diff++) {       if (s[first_diff - 1] != s[first_diff]) break;     }     if (first_diff == n) return (n + 2) / 3;     s = s.substr(first_diff, n - first_diff) + s.substr(0, first_diff);     int start = 0;     int ans = 0;     for (int i = 1; i < n; i++) {       if (s[i] != s[i - 1]) {         ans += (i - start) / 3;         start = i;       }     }     ans += (n - start) / 3;     return ans;   }   void work() {     pair<int, string> in = input();     int n = in.first;     string s = in.second;     cout << work2(n, s) << endl;   }   int main() {     int t;     cin >> t;     while (t--) {       work();     }     return 0;   }   