func_code_string: #include <bits/stdc++.h>   using namespace std;   const int MAXN = 300005;   int n, m;   char s[MAXN];   int g[22][22];   int dp[1 << 21];   int sol(int msk) {     if (1 << m == msk + 1) return 0;     if (dp[msk] != -1) return dp[msk];     int tk[20] = {0};     int ntk[20] = {0};     int tksz = 0;     int ntksz = 0;     for (int i = 0; i < m; i++) {       if (msk & (1 << i))         tk[tksz++] = i;       else         ntk[ntksz++] = i;     }     int all = 0;     int save = 0;     int best = 10000000;     for (int i = 0; i < ntksz; i++) {       save = 0;       int x = ntk[i];       for (int j = 0; j < tksz; j++) {         int y = tk[j];         save += g[x][y] + g[y][x];       }       best = min(best, -save + sol(msk | (1 << ntk[i])));       all += save;     }     return dp[msk] = best + all;   }   int main() {     memset(dp, -1, sizeof(dp));     scanf( %d %d , &n, &m);     scanf( %s , s);     for (int i = 1; i < n; i++) {       g[s[i - 1] -  a ][s[i] -  a ]++;     }     for (int i = 0; i < m; i++) g[i][i] = 0;     int ans = sol(0);     for (int i = 0; i < m; i++)       for (int j = 0; j < m; j++) ans += g[i][j];     printf( %d n , ans);   }   