func_code_string: #include <bits/stdc++.h>   using namespace std;   const int N = 80, Inf = 0x3f3f3f3f;   int n, f[N][N][N][2];   int pos[3][N], num[3][N];   char s[N];   inline int getid(char ch) {     if (ch ==  V ) return 0;     if (ch ==  K ) return 1;     return 2;   }   inline int move(int i, int j, int k, int id) {     return max(0, num[0][id] - i) + max(0, num[1][id] - j) +            max(0, num[2][id] - k) - 1;   }   int main() {     ios::sync_with_stdio(false);     cin >> n >> s + 1;     for (int i = 1; i <= n; ++i) {       int now = getid(s[i]);       for (int j = 0; j < 3; ++j) num[j][i] = num[j][i - 1];       pos[now][++num[now][i]] = i;     }     memset(f, 0x3f, sizeof f);     f[0][0][0][0] = 0;     for (int i = 0; i <= num[0][n]; ++i)       for (int j = 0; j <= num[1][n]; ++j)         for (int k = 0; k <= num[2][n]; ++k)           for (int fl = 0; fl < 2; ++fl) {             if (i < num[0][n])               f[i + 1][j][k][1] =                   min(f[i + 1][j][k][1],                       f[i][j][k][fl] + move(i, j, k, pos[0][i + 1]));             if (j < num[1][n] && !fl)               f[i][j + 1][k][0] =                   min(f[i][j + 1][k][0],                       f[i][j][k][fl] + move(i, j, k, pos[1][j + 1]));             if (k < num[2][n])               f[i][j][k + 1][0] =                   min(f[i][j][k + 1][0],                       f[i][j][k][fl] + move(i, j, k, pos[2][k + 1]));           }     cout << min(f[num[0][n]][num[1][n]][num[2][n]][0],                 f[num[0][n]][num[1][n]][num[2][n]][1])          << endl;     return 0;   }   