func_code_string: #include <bits/stdc++.h>   using namespace std;   char s[1200005];   long long num[30][30];   int b[1200005], c[1200005], cnt, tot;   long long dp[1200005];   int main() {     memset(dp, 0x3f, sizeof dp);     int n, m;     scanf( %d%d , &n, &m);     scanf( %s , s + 1);     for (int i = 1; i <= n; i++) {       if (i >= 2) {         num[s[i - 1] -  a ][s[i] -  a ]++;         num[s[i] -  a ][s[i - 1] -  a ]++;       }       if (i <= n - 1) {         num[s[i + 1] -  a ][s[i] -  a ]++;         num[s[i] -  a ][s[i + 1] -  a ]++;       }     }     int all = (1 << m) - 1;     dp[0] = 0;     for (int i = 1; i <= all; i++) {       tot = cnt = 0;       dp[i] = 1e18;       for (int j = 0; j < m; j++) {         if ((i >> j) & 1) {           b[++cnt] = j;         } else {           c[++tot] = j;         }       }       for (int j = 1; j <= cnt; j++) {         dp[i] = min(dp[i], dp[i ^ (1 << b[j])]);       }       for (int j = 1; j <= cnt; j++) {         for (int k = 1; k <= tot; k++) {           dp[i] += num[b[j]][c[k]] / 2;         }       }     }     cout << dp[all] << endl;   }   