from itertools import takewhile

INF = 1e9

n, e = map(int, input().split())
keys = [input() for _ in range(n)]

def count(key, c):
    l = len(list(takewhile(lambda cc: cc == c, key)))
    return INF if l == len(key) else l

l, c = min((
        (sum(count(key, c) for key in keys), c) 
        for c in (chr(i + ord('a')) 
        for i in range(e))
    ))
print('NO' if l >= INF else c * (l + 1))
