I,R=input,range N,K=map(int,I().split()) M=set() P=pow(5,K-1) for i in R(N): S=int(I(),5) for m in M: s,t,p,b=S,m,P,0 for j in R(K):s,t,p,b=s%p,t%p,p//5,b+(t