#include int is_smaller(int K, char s[], char t[]) { int i; for (i = 0; i < K; i++) if (s[i] > t[i]) return 0; return 1; } int main() { int i, N, K; char S[200001][10]; scanf("%d %d", &N, &K); for (i = 1; i <= N; i++) scanf("%s", S[i]); int j, next[200003], prev[200003]; for (i = 1, next[0] = 1, prev[N+1] = N; i <= N; i++) { next[i] = i + 1; prev[i] = i - 1; } for (i = 1; i <= N; i++) { for (j = next[0]; j < i; j = next[j]) { if (is_smaller(K, S[j], S[i])) { j = prev[j]; next[j] = next[next[j]]; prev[next[j]] = j; } else if (is_smaller(K, S[i], S[j])) { next[prev[i]] = next[i]; prev[next[i]] = prev[i]; break; } } } int ans = 0; for (i = next[0]; i <= N; i = next[i]) ans++; printf("%d\n", N - ans); fflush(stdout); return 0; }