You are given an *n* × *m* rectangular table consisting of lower case English letters. In one operation you can completely remove one column from the table. The remaining parts are combined forming a new table. For example, after removing the second column from the table

 

we obtain the table:

 

A table is called good if its rows are ordered from top to bottom lexicographically, i.e. each row is lexicographically no larger than the following one. Determine the minimum number of operations of removing a column needed to make a given table good.
The first line contains two integers  — *n* and *m* (1 ≤ *n*, *m* ≤ 100).

Next *n* lines contain *m* small English letters each — the characters of the table.
n, m = map(int, input().split())
A = []
for i in range(n):
    A.append(input())
num = n
f = False
for j in range(m):
    f = True
    for i in range(1, n):
        if A[i][j] >= A[i - 1][j]:
            continue
        else:
            f = False
            break
    if f:
        num = j
        break
if not f:
    num = m
l = 0
r = 0
if m > num: c = 1
else: c = 0
while num < m:
    onum = num
##    print(num)
    t = []
    for i in range(1, n):
        if A[i][num] == A[i - 1][num]:
            r += 1
        else:
            if r - l >= 1:
                t.append((l, r))
            l = i
            r = i
##    print(t, num, onum)
##    if input() != 'ok': break
    f = True
    for j in range(num + 1, m):
        f = True
        for k in range(len(t)):
            f2 = True
            for i in range(t[k][0] + 1, t[k][1] + 1):
##                print(i, j)
##                print(A[i][j], A[i - 1][j])
                if A[i][j] >= A[i - 1][j]:
                    continue
                else:
                    f = False
                    f2 = False
                    break
            if not f2:
                break
        if f:
            num = j
            break
    if not f or num == onum: num = m
    else: c += 1
print(m - c)
    
            
