Bees Alice and Alesya gave beekeeper Polina famous card game "Set" as a Christmas present. The deck consists of cards that vary in four features across three options for each kind of feature: number of shapes, shape, shading, and color. In this game, some combinations of three cards are said to make up a set. For every feature — color, number, shape, and shading — the three cards must display that feature as either all the same, or pairwise different. The picture below shows how sets look.

<image>

Polina came up with a new game called "Hyperset". In her game, there are n cards with k features, each feature has three possible values: "S", "E", or "T". The original "Set" game can be viewed as "Hyperset" with k = 4.

Similarly to the original game, three cards form a set, if all features are the same for all cards or are pairwise different. The goal of the game is to compute the number of ways to choose three cards that form a set.

Unfortunately, winter holidays have come to an end, and it's time for Polina to go to school. Help Polina find the number of sets among the cards lying on the table.

Input

The first line of each test contains two integers n and k (1 ≤ n ≤ 1500, 1 ≤ k ≤ 30) — number of cards and number of features.

Each of the following n lines contains a card description: a string consisting of k letters "S", "E", "T". The i-th character of this string decribes the i-th feature of that card. All cards are distinct.

Output

Output a single integer — the number of ways to choose three cards that form a set.

Examples

Input


3 3
SET
ETS
TSE


Output


1

Input


3 4
SETE
ETSE
TSES


Output


0

Input


5 4
SETT
TEST
EEET
ESTE
STES


Output


2

Note

In the third example test, these two triples of cards are sets:

  1. "SETT", "TEST", "EEET" 
  2. "TEST", "ESTE", "STES" 
import java.util.*;
import java.lang.*;
import java.io.*;
import java.math.BigInteger; 

public class Codechef
{
    static long fac[] = new long[1000001];
    static void perm()
    {
        fac[0]=1;
        for (int x=1;x<=1000000;x++)
        fac[x]=fac[x-1]*x;
    }
    static long power(long x, long y, long p) 
    { 
          
        // Initialize result 
        long res = 1; 
      
        // Update x if it is more than or 
        // equal to p 
        x = x % p; 
                      
        while (y > 0) 
        { 
              
            // If y is odd, multiply x 
            // with result 
            if (y % 2 == 1) 
                res = (res * x) % p; 
      
            // y must be even now 
            y = y >> 1; // y = y/2 
            x = (x * x) % p; 
        } 
          
        return res; 
    } 
    // Returns n^(-1) mod p 
    static long modInverse(long n, long p) 
    { 
        return power(n, p-2, p); 
    } 
      
    // Returns nCr % p using Fermat's 
    // little theorem. 
    static long nPr(int n, int r, 
                                    long p) 
    { 
          
        // Base case 
        if (r == 0) 
            return 1; 
      
        // Fill factorial array so that we 
        // can find all factorial of r, n 
        // and n-r 
      
        return ((fac[n] % p) * modInverse(fac[n-r], p) 
                                    % p) % p; 
    }
static long mod(String num, long a) 
    { 
          
        // Initialize result 
        long res = 0; 
  
        // One by one process all digits of 'num' 
        for (int i = 0; i < num.length(); i++) 
            res = (res * 10 + (int)num.charAt(i) 
                                     - '0') % a; 
  
        return res; 
    }
    static boolean check (int a)
    {
        String s=Integer.toString(a);
        int f[] = new int[10];
        for (int x=0;x<s.length();x++)
        {
            f[s.charAt(x)-'0']++;
            if (f[s.charAt(x)-'0']>1)
            return (false);
        }
        return (true);
    }
    static long lcm(int[] element_array) 
    { 
        long lcm_of_array_elements = 1; 
        int divisor = 2; 
          
        while (true) { 
            int counter = 0; 
            boolean divisible = false; 
              
            for (int i = 0; i < element_array.length; i++) { 
  
                // lcm_of_array_elements (n1, n2, ... 0) = 0. 
                // For negative number we convert into 
                // positive and calculate lcm_of_array_elements. 
  
                if (element_array[i] == 0) { 
                    return 0; 
                } 
                else if (element_array[i] < 0) { 
                    element_array[i] = element_array[i] * (-1); 
                } 
                if (element_array[i] == 1) { 
                    
                    
                    counter++; 
                } 
  
                // Divide element_array by devisor if complete 
                // division i.e. without remainder then replace 
                // number with quotient; used for find next factor 
                if (element_array[i] % divisor == 0) { 
                    divisible = true; 
                    element_array[i] = element_array[i] / divisor; 
                } 
            } 
  
            // If divisor able to completely divide any number 
            // from array multiply with lcm_of_array_elements 
            // and store into lcm_of_array_elements and continue 
            // to same divisor for next factor finding. 
            // else increment divisor 
            if (divisible) { 
                lcm_of_array_elements = lcm_of_array_elements * divisor; 
            } 
            else { 
                divisor++; 
            } 
  
            // Check if all element_array is 1 indicate  
            // we found all factors and terminate while loop. 
            if (counter == element_array.length) { 
                return lcm_of_array_elements; 
            } 
        } 
    }
    static boolean find(int N)
    {
        String r="";
        int rem=1%N;
        HashMap<Integer, Integer> h = new HashMap<Integer, Integer>();
        while ((rem!=0) && !h.containsKey(rem))
        {
            h.put(rem,r.length());
            rem=rem*10;
            r=r+(rem/N);
            rem=rem%N;
        }
        if (rem==0)
        return (false);
        else
        return (true);
    }
    static String sorts(String inputString) 
    { 
        // convert input string to char array 
        char tempArray[] = inputString.toCharArray(); 
          
        // sort tempArray 
        Arrays.sort(tempArray); 
          
        // return new sorted string 
        return new String(tempArray); 
    }
    static long qrt(double d)
    {
        long k=(long)(d);
        double x=-1+Math.sqrt(1+(8*d));
        x=x/2;
        long w=(long)(Math.ceil(x));
        long sum=w*(w+1);
        sum=sum/2;
        //System.out.println (w+"GDSGDS");
        while (sum%2!=k%2)
        {
            w++;
            sum=w*(w+1);
            sum=sum/2;
        }
        return (w);
    }
    static int knapSack(long W, int wt[], int val[], int n) 
     { 
        // Base Case 
    if (n <=0 || W == 0) 
        return 0; 
    if (wt[n-1] > W) 
       return knapSack(W, wt, val, n-1); 
    else 
    return Math.max( val[n-1] + knapSack(W-wt[n-1], wt, val, n-2), knapSack(W, wt, val, n-1)); 
      } 
    static boolean index(int x, int y, int N, int M)
    {
        if (x>=0 && y>=0 && x<N && y<M)
        return (true);
        else
        return (false);
    }
    static boolean chek(int a[], int l)
    {
        int b[] = new int[l];
        int c[] = new int[l];
        b[0]=a[0];
        for (int x=1;x<l;x++)
        {
            if (b[x-1]>a[x])
            b[x]=a[x];
            else
            b[x]=b[x-1];
        }
        c[l-1]=a[l-1];
        for (int x=l-2;x>=0;x--)
        {
            if (c[x+1]<a[x])
            c[x]=a[x];
            else
            c[x]=c[x+1];
        }
        for (int x=0;x<l;x++)
        {
            if (b[x]<c[x])
            return (true);
        }
        return (false);
    }
    static long a[] = new long[250001];
    static void fact(long m)
    {
        a[0]=1;
        for (int x=1;x<=250000;x++)
        a[x]=((a[x-1]%m)*(x%m))%m;
    }
	public static void main (String[] args) throws java.lang.Exception
	{
	    Scanner in = new Scanner(System.in);
	    int N=in.nextInt();
	    int K=in.nextInt();
	    String a[] = new String[N];
	    HashMap<String,Integer> h = new HashMap<String,Integer>();
	    for (int x=0;x<N;x++)
	    {
	        a[x]=in.next();
	        if (!h.containsKey(a[x]))
	        h.put(a[x],x);
	    }
	    String d="";
	    char z1;char z2;
	    int num=(int)('S')+(int)('E')+(int)('T');
	    int ans=0;
	    for (int x=0;x<N-2;x++)
	    {
	        for (int y=x+1;y<N-1;y++)
	        {
	            d="";
	            for (int z=0;z<K;z++)
	            {
	                z1=a[x].charAt(z);
	                z2=a[y].charAt(z);
	                if (z1==z2)
	                d=d+z1;
	                else
	                {
	                   int le=num-(int)(z1)-(int)(z2);
	                   d=d+(char)(le);
	                }
	            }
	            if (h.containsKey(d))
	            {
	                if (h.get(d)>y)
	                ans++;
	            }
	        }
	    }
	    System.out.println (ans);
	    
	}
  static class Reader
    {
        final private int BUFFER_SIZE = 1 << 16;
        private DataInputStream din;
        private byte[] buffer;
        private int bufferPointer, bytesRead;
 
        public Reader()
        {
            din = new DataInputStream(System.in);
            buffer = new byte[BUFFER_SIZE];
            bufferPointer = bytesRead = 0;
        }
 
        public Reader(String file_name) throws IOException
        {
            din = new DataInputStream(new FileInputStream(file_name));
            buffer = new byte[BUFFER_SIZE];
            bufferPointer = bytesRead = 0;
        }
 
        public String readLine() throws IOException
        {
            byte[] buf = new byte[64]; // line length
            int cnt = 0, c;
            while ((c = read()) != -1)
            {
                if (c == '\n')
                    break;
                buf[cnt++] = (byte) c;
            }
            return new String(buf, 0, cnt);
        }
 
        public int nextInt() throws IOException
        {
            int ret = 0;
            byte c = read();
            while (c <= ' ')
                c = read();
            boolean neg = (c == '-');
            if (neg)
                c = read();
            do
            {
                ret = ret * 10 + c - '0';
            }  while ((c = read()) >= '0' && c <= '9');
 
            if (neg)
                return -ret;
            return ret;
        }
 
        public long nextLong() throws IOException
        {
            long ret = 0;
            byte c = read();
            while (c <= ' ')
                c = read();
            boolean neg = (c == '-');
            if (neg)
                c = read();
            do {
                ret = ret * 10 + c - '0';
            }
            while ((c = read()) >= '0' && c <= '9');
            if (neg)
                return -ret;
            return ret;
        }
 
        public double nextDouble() throws IOException
        {
            double ret = 0, div = 1;
            byte c = read();
            while (c <= ' ')
                c = read();
            boolean neg = (c == '-');
            if (neg)
                c = read();
 
            do {
                ret = ret * 10 + c - '0';
            }
            while ((c = read()) >= '0' && c <= '9');
 
            if (c == '.')
            {
                while ((c = read()) >= '0' && c <= '9')
                {
                    ret += (c - '0') / (div *= 10);
                }
            }
 
            if (neg)
                return -ret;
            return ret;
        }
 
        private void fillBuffer() throws IOException
        {
            bytesRead = din.read(buffer, bufferPointer = 0, BUFFER_SIZE);
            if (bytesRead == -1)
                buffer[0] = -1;
        }
 
        private byte read() throws IOException
        {
            if (bufferPointer == bytesRead)
                fillBuffer();
            return buffer[bufferPointer++];
        }
 
        public void close() throws IOException
        {
            if (din == null)
                return;
            din.close();
        }
    }
}