Ti-am facut o sursa in C++ folosind functia strstr. Am mai folosit si alte doua siruri auxiliare dar important este de fapt numararea silabelor. Problema am extras-o dintr-o varianta de bac si am adaptat-o. Succes!
#include <bits/stdc++.h>using namespace std;int n, i, k;char s[260], *p, t[260] = "MA", aux[260];int main(){ cin.getline(s, sizeof(s));
p = strstr(s, t); while(p != NULL) { n = strlen(s); memset(aux, 0, sizeof(t)); strncpy(aux, s, n - strlen(p)); strcat(aux, p + strlen(t)); memset(s, 0, sizeof(s)); strcpy(s, aux); k ++; p = strstr(p, t); if(p == NULL) break; } cout << k; return 0;}