func_code_string: #include <bits/stdc++.h>   using namespace std;   long long dp[1050000], k[25][25], a[1050000];   int main() {     long long n, m;     while (scanf( %lld%lld , &n, &m) == 2) {       string s;       cin >> s;       memset(k, 0, sizeof(k));       for (int i = 1; i < s.length(); i++) {         k[s[i - 1] -  a ][s[i] -  a ]++;         k[s[i] -  a ][s[i - 1] -  a ]++;       }       long long an = (1 << m) - 1;       dp[0] = a[0] = 0;       for (int i = 1; i <= an; i++) {         dp[i] = 1e17 + 5;         a[i] = 0;         for (int f = 0; f < m; f++) {           if (i & (1 << f)) {             dp[i] = min(dp[i], dp[i ^ (1 << f)] + a[i ^ (1 << f)]);           }         }         for (int f = 0; f < m; f++) {           for (int j = f + 1; j < m; j++) {             if (((i >> f) & 1) ^ ((i >> j) & 1)) {               a[i] += k[f][j];             }           }         }       }       printf( %lld n , dp[an]);     }   }   