Code: Passing the Ball
#include <bits/stdc++.h>
int main() {
std::ios::sync_with_stdio(false);
std::cin.tie(nullptr);
std::cout.tie(nullptr);
int T;
std::cin >> T;
while (T--) {
int n;
std::string s;
std::set<int> vis;
std::cin >> n >> s;
int p = 0;
for (int i = 0; i < n; i++) {
vis.insert(p);
p += s[p] == 'L' ? -1 : 1;
}
vis.insert(p);
std::cout << vis.size() << std::endl;
}
return 0;
}