func_code_string: #include <bits/stdc++.h>   using namespace std;   int num[10010];   int dp[1 << 18];   int bad[1 << 18];   int g[100][100];   int tmp[1 << 18];   string s;   int get(int l, int r) {     int t = 0;     for (int i = l; i <= r; ++i) {       t |= 1 << (s[i] -  a );     }     return t;   }   int main() {     int n, p;     scanf( %d%d , &n, &p);     cin >> s;     memset(num, 0, sizeof(num));     memset(g, 0, sizeof(g));     memset(bad, 0, sizeof(bad));     for (int i = 0; i < s.size(); ++i) {       num[s[i] -  a ]++;     }     for (int i = 0; i < p; ++i) {       for (int j = 0; j < p; ++j) {         scanf( %d , &g[i][j]);       }     }     for (int i = 0; i < p; ++i) {       for (int j = 0; j < p; ++j) {         if (g[i][j]) continue;         memset(tmp, 0, sizeof(tmp));         int l = -1;         for (int k = 0; k < s.size(); ++k) {           if (s[k] -  a  == i || s[k] -  a  == j) {             if (l == -1) {               l = k;             } else {               int a = s[l] -  a , b = s[k] -  a ;               if ((a == i || a == j) && (b == i || b == j)) {                 if ((a == i && b == j) || (b == j && a == i)) {                   int m = get(l + 1, k - 1);                   tmp[m] = 1;                 }                 l = k;               }             }           }         }         for (int ii = 0; ii < (1 << p); ++ii) {           if ((ii & (1 << i)) || (ii & (1 << j))) continue;           for (int k = 0; k < p; ++k) {             if (k == i || k == j) continue;             tmp[ii | (1 << k)] |= tmp[ii];           }           if (tmp[ii]) bad[ii] = tmp[ii];         }       }     }     memset(dp, 0, sizeof(dp));     dp[0] = 1;     int ans = 0;     for (int i = 0; i < (1 << p); ++i) {       if (bad[i]) continue;       for (int j = 0; j < p; ++j) {         if ((1 << j) & i) {           if (dp[i ^ (1 << j)]) dp[i] = 1;         }       }       if (dp[i]) {         int s = 0;         for (int j = 0; j < p; ++j) {           if ((1 << j) & i) s += num[j];         }         ans = max(ans, s);       }     }     printf( %d n , n - ans);   }   