1 #include<bits/stdc++.h>
2 #define lowbit(a) ((a)&(-(a)))
3 #define clr(a,x) memset(a,x,sizeof(a))
4 #define rep(i,l,r) for(int i=l;i<(r);i++)
5 typedef unsigned long long ull;
6 typedef long long ll;
7 using namespace std;
8 int read()
9 {
10 char c=getchar();
11 int ans=0,f=1;
12 while(!isdigit(c)){
13 if(c==‘-‘) f=-1;
14 c=getchar();
15 }
16 while(isdigit(c)){
17 ans=ans*10+c-‘0‘;
18 c=getchar();
19 }
20 return ans*f;
21 }
22 const int maxn=30009,maxl=209,p=20011;
23 int n,l,nouse;
24 ull ans=0,h[maxn][maxl],power[maxl],a[maxn];
25 int main()
26 {
27 n=read();l=read();nouse=read();
28 rep(i,0,n){
29 char s[maxl];
30 scanf("%s",&s);
31 rep(j,0,l) h[i][j]=(j?h[i][j-1]:0)*p+s[j];
32 }
33 power[0]=1;
34 rep(i,1,l+1) power[i]=power[i-1]*p;
35 rep(i,0,l){
36 rep(j,0,n){
37 a[j]=h[j][l-1]-h[j][i]*power[l-i-1]+(i?h[j][i-1]:0)*power[l-i];
38 }
39 sort(a,a+n);
40 ull cnt=0;
41 rep(j,1,n){
42 if(a[j]==a[j-1]) ans+=(++cnt);
43 else cnt=0;
44 }
45 }
46 cout<<ans<<endl;
47 return 0;
48 }