#include #include using ll = long long; #define MOD 1000000007 using namespace std; int main(){ int N; ll cnt = 0; string S; cin >> N; cin >> S; for(int i = 0; i < N-2; i++) { if (S[i] == 'U') { for(int j = i+1; j < N-1; j++) { if (S[j] == 'M') { if (2*j-i