func_code_string: #include <bits/stdc++.h>   using namespace std;   char s[100005];   int n, k, cnt[20];   bool a[20][20], mark[1 << 17], tmp[1 << 17];   inline void work(int x, int y) {     memset(tmp, 0, sizeof(tmp));     for (int i = 1, j, t; i <= n;) {       while (i <= n && s[i] -  a  != x) i++;       j = i + 1;       t = 0;       while (j <= n && s[j] -  a  != x && s[j] -  a  != y) {         t |= 1 << s[j] -  a ;         j++;       }       if (j > n) break;       if (s[j] -  a  == y) tmp[t] = 1;       if (s[j] -  a  == x)         i = j;       else         i = j + 1;     }     for (int i = 1; i < 1 << k; i++) {       if (!tmp[i]) continue;       mark[i] = 1;       for (int j = 0; j < k; j++)         if (j != x && j != y) tmp[i | 1 << j] = 1;     }   }   bool f[1 << 17];   int main() {     cin >> n >> k;     scanf( %s , s);     for (int i = 0; i < n; i++) cnt[s[i] -  a ]++;     for (int i = 0; i < k; i++)       for (int j = 0; j < k; j++) {         cin >> a[i][j];         if (!a[i][j]) work(i, j);       }     f[0] = 1;     for (int i = 0; i < 1 << k; i++) {       if (!f[i]) continue;       for (int j = 0; j < k; j++)         if (!mark[i | 1 << j]) f[i | 1 << j] = 1;     }     int ans = 0;     for (int i = 0; i < 1 << k; i++) {       if (!f[i]) continue;       int t = 0;       for (int j = 0; j < k; j++)         if (i & 1 << j) t += cnt[j];       ans = max(ans, t);     }     cout << n - ans;     return 0;   }   