func_code_string: #include <bits/stdc++.h>   using namespace std;   int dp[5005][15], oo = 1e5;   char str[5005];   int solve(int i, int s) {     if (str[i] == 0 and s == 2) {       return 0;     } else if (str[i] == 0 and s != 2) {       return oo;     } else if (~dp[i][s]) {       return dp[i][s];     } else {       int ans = 0;       if (s == 0) {         if (str[i] ==  a ) {           ans = min(solve(i + 1, s), solve(i + 1, 1));         } else {           ans = min(solve(i + 1, s) + 1, solve(i + 1, 1));         }       } else if (s == 1) {         if (str[i] ==  b ) {           ans = min(solve(i + 1, s), solve(i + 1, 2));         } else {           ans = min(solve(i + 1, s) + 1, solve(i + 1, 2));         }       } else if (s == 2) {         if (str[i] ==  a ) {           ans = solve(i + 1, s);         } else {           ans = solve(i + 1, s) + 1;         }       }       return dp[i][s] = ans;     }   }   int main() {     scanf(  %s , str);     memset(dp, -1, sizeof dp);     if (str[1] == 0) {       printf( 1 n );     } else {       printf( %d n , strlen(str) - solve(0, 0));     }     return 0;   }   