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.math.*;
import java.io.*;
import java.util.*;
import java.awt.*;


public class CP {
    public static void main(String[] args) throws Exception {
        new Solver().solve();
    }
}

class Solver {
    final Helper hp;
    final int MAXN = 1000_006;
    final long MOD = (long) 1e9 + 7;

    Solver() {
        hp = new Helper(MOD, MAXN);
        hp.initIO(System.in, System.out);
    }

    int N, K;
    HashMap<String, Integer> S;
    String[] A;

    void solve() throws Exception {
        int i, j, k;

        N = hp.nextInt();
        K = hp.nextInt();
        S = new HashMap<>();
        for (i = 0; i < N; ++i) {
            String s = hp.next();
            S.put(s, S.getOrDefault(s, 0) + 1);
        }

        N = S.size();
        A = new String[N];
        k = 0;
        for (String key : S.keySet()) A[k++] = key;

        ArrayList<Integer> hs = new ArrayList<>();
        for (i = 0; i < N; ++i) hs.add(i);
        hp.println(recurse(0, hs));

        hp.flush();
    }

    long recurse(int idx, ArrayList<Integer> bs) {
        //System.out.println(idx + " " + bs);

        if (idx >= K || bs.size() < 3) {
            long c = 0;
            for (int itr : bs) c += S.get(A[itr]);
            return c * (c - 1) * (c - 2) / 6;
        }

        ArrayList<Integer> s = new ArrayList<>(), e = new ArrayList<>(), t = new ArrayList<>();
        for (int i : bs) {
            switch (A[i].charAt(idx)) {
                case 'S': s.add(i); break;
                case 'E': e.add(i); break;
                case 'T': t.add(i); break;
                default: System.exit(7 / 0);
            }
        }

        long ans = recurse(idx + 1, s) + recurse(idx + 1, e) + recurse(idx + 1, t);
        for (int i : s) {
            for (int j : e) {
                StringBuilder tmp = new StringBuilder();
                for (int z = 0; z < K; ++z) tmp.append(calc(A[i].charAt(z), A[j].charAt(z)));
                ans += S.get(A[i]) * S.get(A[j]) * S.getOrDefault(tmp.toString(), 0);
            }
        }
        return ans;
    }

    char calc(int a, int b) {
        return (char) ((a == b) ? a : 'S' ^ 'E' ^ 'T' ^ a ^ b);
    }
}

/*
class Solver {
    final Helper hp;
    final int MAXN = 1000_006;
    final long MOD = (long) 1e9 + 7;

    Solver() {
        hp = new Helper(MOD, MAXN);
        hp.initIO(System.in, System.out);
    }

    int N, K;
    String[] A;

    void solve() throws Exception {
        int i, j, k;

        //N = hp.nextInt(); K = hp.nextInt();
        //A = hp.getStringArray(N);


        Random rnd = new Random();
        N = 1000; K = 30;
        A = new String[N];
        for (i = 0; i < N; ++i) {
            String s = "";
            for (j = 0; j < K; ++j) {
                switch (rnd.nextInt(3)) {
                    case 0: s += 'S'; break;
                    case 1: s += 'E'; break;
                    case 2: s += 'T'; break;
                    default: System.exit(7 / 0);
                }
            }
            A[i] = s;
        }

        BitSet bs = new BitSet();
        bs.set(0, N);
        hp.println(recurse(0, bs));

        hp.flush();
    }

    long recurse(int idx, BitSet bs) {
        if (bs.cardinality() < 3) {
            return 0;
        } else if (idx >= K) {
            long c = bs.cardinality();
            return c * (c - 1) * (c - 2) / 6;
        }

        BitSet s = new BitSet(), e = new BitSet(), t = new BitSet();
        for (int i = bs.nextSetBit(0); i >= 0; i = bs.nextSetBit(i + 1)) {
            switch (A[i].charAt(idx)) {
                case 'S': s.set(i); break;
                case 'E': e.set(i); break;
                case 'T': t.set(i); break;
                default: System.exit(7 / 0);
            }
        }

        long ans = recurse(idx + 1, s) + recurse(idx + 1, e) + recurse(idx + 1, t);
        int i, j, k;
        for (i = s.nextSetBit(0); i >= 0; i = s.nextSetBit(i + 1)) {
            for (j = e.nextSetBit(0); j >= 0; j = e.nextSetBit(j + 1)) {
                for (k = t.nextSetBit(0); k >= 0; k = t.nextSetBit(k + 1)) {
                    if (check(new int[] {i, j, k})) ++ans;
                }
            }
        }
        return ans;
    }

    boolean check(int[] idx) {
        for (int i = 0; i < K; ++i) {
            int s = 0, e = 0, t = 0;

            for (int id : idx) {
                switch (A[id].charAt(i)) {
                    case 'S': ++s; break;
                    case 'E': ++e; break;
                    case 'T': ++t; break;
                    default: System.exit(7 / 0);
                }
            }

            if (s == 1 && e == 1 && t == 1) ;
            else if (s == 3 || e == 3 || t == 3) ;
            else return false;
        }
        return true;
    }
}*/

class Helper {
    final long MOD;
    final int MAXN;
    final Random rnd;

    public Helper(long mod, int maxn) {
        MOD = mod;
        MAXN = maxn;
        rnd = new Random();
    }


    public static int[] sieve;
    public static ArrayList<Integer> primes;

    public void setSieve() {
        primes = new ArrayList<>();
        sieve = new int[MAXN];
        int i, j;
        for (i = 2; i < MAXN; ++i)
            if (sieve[i] == 0) {
                primes.add(i);
                for (j = i; j < MAXN; j += i) {
                    sieve[j] = i;
                }
            }
    }


    public static long[] factorial;

    public void setFactorial() {
        factorial = new long[MAXN];
        factorial[0] = 1;
        for (int i = 1; i < MAXN; ++i) factorial[i] = factorial[i - 1] * i % MOD;
    }

    public long getFactorial(int n) {
        if (factorial == null) setFactorial();
        return factorial[n];
    }

    public long ncr(int n, int r) {
        if (r > n) return 0;
        if (factorial == null) setFactorial();
        long numerator = factorial[n];
        long denominator = factorial[r] * factorial[n - r] % MOD;
        return numerator * pow(denominator, MOD - 2, MOD) % MOD;
    }


    public long[] getLongArray(int size) throws Exception {
        long[] ar = new long[size];
        for (int i = 0; i < size; ++i) ar[i] = nextLong();
        return ar;
    }

    public int[] getIntArray(int size) throws Exception {
        int[] ar = new int[size];
        for (int i = 0; i < size; ++i) ar[i] = nextInt();
        return ar;
    }

    public String[] getStringArray(int size) throws Exception {
        String[] ar = new String[size];
        for (int i = 0; i < size; ++i) ar[i] = next();
        return ar;
    }

    public String joinElements(long[] ar) {
        StringBuilder sb = new StringBuilder();
        for (long itr : ar) sb.append(itr).append(" ");
        return sb.toString().trim();
    }


    public String joinElements(int[] ar) {
        StringBuilder sb = new StringBuilder();
        for (int itr : ar) sb.append(itr).append(" ");
        return sb.toString().trim();
    }

    public String joinElements(String[] ar) {
        StringBuilder sb = new StringBuilder();
        for (String itr : ar) sb.append(itr).append(" ");
        return sb.toString().trim();
    }

    public String joinElements(Object[] ar) {
        StringBuilder sb = new StringBuilder();
        for (Object itr : ar) sb.append(itr).append(" ");
        return sb.toString().trim();
    }


    public long gcd(long a, long b) {
        return b == 0 ? a : gcd(b, a % b);
    }

    public int gcd(int a, int b) {
        return b == 0 ? a : gcd(b, a % b);
    }


    public long max(long[] ar) {
        long ret = ar[0];
        for (long itr : ar) ret = Math.max(ret, itr);
        return ret;
    }

    public int max(int[] ar) {
        int ret = ar[0];
        for (int itr : ar) ret = Math.max(ret, itr);
        return ret;
    }

    public long min(long[] ar) {
        long ret = ar[0];
        for (long itr : ar) ret = Math.min(ret, itr);
        return ret;
    }

    public int min(int[] ar) {
        int ret = ar[0];
        for (int itr : ar) ret = Math.min(ret, itr);
        return ret;
    }


    public long sum(long[] ar) {
        long sum = 0;
        for (long itr : ar) sum += itr;
        return sum;
    }

    public long sum(int[] ar) {
        long sum = 0;
        for (int itr : ar) sum += itr;
        return sum;
    }

    public void shuffle(int[] ar) {
        int r;
        for (int i = 0; i < ar.length; ++i) {
            r = rnd.nextInt(ar.length);
            if (r != i) {
                ar[i] ^= ar[r];
                ar[r] ^= ar[i];
                ar[i] ^= ar[r];
            }
        }
    }

    public void shuffle(long[] ar) {
        int r;
        for (int i = 0; i < ar.length; ++i) {
            r = rnd.nextInt(ar.length);
            if (r != i) {
                ar[i] ^= ar[r];
                ar[r] ^= ar[i];
                ar[i] ^= ar[r];
            }
        }
    }

    public long pow(long base, long exp, long MOD) {
        base %= MOD;
        long ret = 1;
        while (exp > 0) {
            if ((exp & 1) == 1) ret = ret * base % MOD;
            base = base * base % MOD;
            exp >>= 1;
        }
        return ret;
    }


    static byte[] buf = new byte[2048];
    static int index, total;
    static InputStream in;
    static BufferedWriter bw;


    public void initIO(InputStream is, OutputStream os) {
        try {
            in = is;
            bw = new BufferedWriter(new OutputStreamWriter(os));
        } catch (Exception e) {
        }
    }

    public void initIO(String inputFile, String outputFile) {
        try {
            in = new FileInputStream(inputFile);
            bw = new BufferedWriter(new OutputStreamWriter(
                    new FileOutputStream(outputFile)));
        } catch (Exception e) {
        }
    }

    private int scan() throws Exception {
        if (index >= total) {
            index = 0;
            total = in.read(buf);
            if (total <= 0)
                return -1;
        }
        return buf[index++];
    }

    public String next() throws Exception {
        int c;
        for (c = scan(); c <= 32; c = scan()) ;
        StringBuilder sb = new StringBuilder();
        for (; c > 32; c = scan())
            sb.append((char) c);
        return sb.toString();
    }

    public int nextInt() throws Exception {
        int c, val = 0;
        for (c = scan(); c <= 32; c = scan()) ;
        boolean neg = c == '-';
        if (c == '-' || c == '+')
            c = scan();
        for (; c >= '0' && c <= '9'; c = scan())
            val = (val << 3) + (val << 1) + (c & 15);
        return neg ? -val : val;
    }

    public long nextLong() throws Exception {
        int c;
        long val = 0;
        for (c = scan(); c <= 32; c = scan()) ;
        boolean neg = c == '-';
        if (c == '-' || c == '+')
            c = scan();
        for (; c >= '0' && c <= '9'; c = scan())
            val = (val << 3) + (val << 1) + (c & 15);
        return neg ? -val : val;
    }

    public void print(Object a) throws Exception {
        bw.write(a.toString());
    }

    public void printsp(Object a) throws Exception {
        print(a);
        print(" ");
    }

    public void println() throws Exception {
        bw.write("\n");
    }

    public void println(Object a) throws Exception {
        print(a);
        println();
    }

    public void flush() throws Exception {
        bw.flush();
    }
}
