func_code_string: #include <bits/stdc++.h>   using namespace std;   const int MAXN = 1005;   char s[MAXN][MAXN];   int n, m, pre[MAXN], nex[MAXN];   bool check[MAXN];   int main() {     scanf( %d%d n , &n, &m);     for (int i = 1; i <= n; ++i) gets(s[i] + 1);     for (int j = 0; j <= m + 1; ++j) pre[j] = j - 1, nex[j] = j + 1;     int res = 0;     for (int j = nex[0]; j <= m; j = nex[j]) {       bool ok = 1;       for (int i = 1; i <= n - 1; ++i) {         if (!check[i] && s[i][j] > s[i + 1][j]) {           ok = 0;           break;         }       }       if (!ok) {         int prevpos = pre[j], nextpos = nex[j];         nex[prevpos] = nextpos;         pre[nextpos] = prevpos;         ++res;       } else {         for (int i = 1; i <= n - 1; ++i)           if (s[i][j] < s[i + 1][j]) check[i] = 1;       }     }     printf( %d , res);   }   