class Solution(object):
    def minDeletionSize(self, A):
        """
        :type A: List[str]
        :rtype: int
        """
        m, n, res = len(A[0]), len(A), 0
        cols = [[] * n for _ in xrange(m)]
        for w in A:
            for k, v in enumerate(w):
                cols[k].append(v)

        for l in cols:
            if l != sorted(l):
                res += 1

        return res


if __name__ == '__main__':
    print Solution().minDeletionSize(["cba", "daf", "ghi"])
    print Solution().minDeletionSize(["a", "b"])
    print Solution().minDeletionSize(["zyx", "wvu", "tsr"])
    print Solution().minDeletionSize(["babca", "bbazb"])
