#include <bits/stdc++.h>
using namespace std;
char s[510][510];
int n, m, N, cnt[510][30], f[510], p[510], ans[510], Ans, mxp;
bool Equel(int i, int j) {
  for (int k = 0; k < 26; k++)
    if (cnt[i][k] != cnt[j][k]) return 0;
  return 1;
}
void check(int i) {
  f[i] = 0;
  for (int j = 0; j < 26; j++)
    if (cnt[i][j] & 1) f[i]++;
}
int main() {
  scanf("%d%d", &n, &m);
  N = n * 2;
  for (int i = 1; i < N; i += 2) scanf("%s", s[i]);
  for (int l = 0; l < m; l++) {
    for (int r = l; r < m; r++) {
      for (int i = 1; i < N; i += 2) {
        cnt[i][s[i][r] - 'a']++;
        check(i);
      }
      mxp = 0;
      for (int i = 1; i < N; i++) {
        if (mxp + p[mxp] < i)
          p[i] = 0;
        else
          p[i] = min(mxp + p[mxp] - i, p[2 * mxp - i]);
        if (f[i] > 1) continue;
        while (i + p[i] + 1 <= N && i - p[i] - 1 >= 0 && f[i + p[i] + 1] < 2 &&
               f[i - p[i] - 1] < 2 && Equel(i - p[i] - 1, i + p[i] + 1))
          p[i]++;
        if (mxp + p[mxp] < i + p[i]) mxp = i;
        ans[i]++, ans[i + p[i] + 1]--;
      }
    }
    memset(cnt, 0, sizeof cnt);
  }
  for (int i = 1; i < N; i++) ans[i] += ans[i - 1];
  for (int i = 1; i < N; i += 2) Ans += ans[i];
  printf("%d\n", Ans);
}
