#include <bits/stdc++.h>
using namespace std;
const int N = 600;
const int M = 30;
char s[N][N];
int p[N][N], t[N][M], a[N], n;
long long ans = 0, sum = 0;
int tt;
bool cmp(int x, int y) {
  if (!(x & 1)) {
    if (a[x / 2] > 1 || a[y / 2] > 1) return false;
    if ((tt & 1) != a[x / 2] || (tt & 1) != a[y / 2]) return false;
  } else
    return true;
  for (int i = 1; i <= 26; i++) {
    if (t[x][i] != t[y][i]) return false;
  }
  return true;
}
int mat[(N << 1)];
long long manacher() {
  int l = (n << 1) + 1;
  sum = 0;
  int mid = 1, r = 1;
  for (int i = 1; i <= 26; i++) {
    t[0][i] = -1, t[l][i] = -2;
  }
  memset(mat, 0, sizeof(mat));
  for (int i = 1; i <= l; i++) {
    if (i <= r)
      mat[i] = min(r - i, mat[(mid << 1) - i]);
    else
      mat[i] = 1;
    while (cmp(i - mat[i], i + mat[i])) mat[i]++;
    if (r < i + mat[i]) {
      r = i + mat[i];
      mid = i;
    }
    if (!(i & 1))
      sum += mat[i] - (mat[i] / 2);
    else
      sum += mat[i] / 2;
  }
  return sum;
}
int main() {
  int m;
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) {
    scanf("%s", s[i] + 1);
    for (int j = 1; j <= m; j++) p[i][j] = s[i][j] - 'a' + 1;
  }
  for (int i = 1; i <= m; i++) {
    memset(a, 0, sizeof(a));
    memset(t, 0, sizeof(t));
    for (int j = i; j <= m; j++) {
      tt = j - i + 1;
      for (int k = 1; k <= n; k++) {
        t[k * 2][p[k][j]]++;
        if (t[k * 2][p[k][j]] % 2)
          a[k]++;
        else
          a[k]--;
      }
      ans += manacher();
    }
  }
  printf("%I64d\n", ans);
  return 0;
}
