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())
l = []
for i in range(n):
    o = input()
    l.append(o)

ans = 0
arr = [""]*n
for i in range(m):
    flag = 0
    for j in range(1,n):
        s1 = arr[j-1]
        s2 = arr[j]
        if s1+l[j-1][i] > s2+l[j][i]:
            flag = 1
            break

    if flag:
        ans += 1
        continue

    for j in range(n):
        arr[j] = arr[j]+l[j][i]

print(ans)