#include <bits/stdc++.h>
const int oo = 2139063143;
const int N = 260;
const int mod = 1000000007;
using namespace std;
inline void sc(long long &x) {
  x = 0;
  static int p;
  p = 1;
  static char c;
  c = getchar();
  while (!isdigit(c)) {
    if (c == '-') p = -1;
    c = getchar();
  }
  while (isdigit(c)) {
    x = (x << 1) + (x << 3) + (c - 48);
    c = getchar();
  }
  x *= p;
}
long long cnt[N], ss[N * 5][N * 5];
long long h[N][N][N];
unsigned long long mi[N];
void initt() {
  mi[1] = 1;
  for (long long i = 2; i <= 26; i++)
    mi[i] = mi[i - 1] * (unsigned long long)19260817;
}
long long gethash() {
  unsigned long long ans = 0;
  for (long long i = 1; i <= 26; i++) ans += mi[i] * (unsigned long long)cnt[i];
  while (ans > 9e18) ans -= 9e18;
  return ans;
}
long long tmp[N * 10], s[N * 10];
long long p[N * 10];
long long n, m;
long long init() {
  memset(p, 0, sizeof(p));
  long long len = n, j = 1;
  s[0] = -1001, s[1] = -1;
  for (long long i = 0; i < len; i++) s[++j] = tmp[i], s[++j] = -1;
  s[++j] = -1002;
  return j;
}
long long manacher() {
  long long len = init();
  long long pos = 1, right = 1, ans = -1;
  for (long long i = 1; i < len; i++)
    if (s[i] > -10000) {
      p[i] = (i >= right) ? 1 : min(right - i, p[(pos << 1) - i]);
      while (s[i - p[i]] == s[i + p[i]]) p[i]++;
      if (right < i + p[i]) pos = i, right = i + p[i];
      ans = max(ans, p[i] - 1);
    }
  return len;
}
long long solve(long long l, long long r) {
  for (long long i = 1; i <= n; i++) tmp[i - 1] = h[i][l][r];
  long long len = manacher();
  long long ans = 0;
  for (long long i = 1; i < len; i++) ans += (p[i] / 2);
  return ans;
}
char sb[N][N];
int main() {
  initt();
  sc(n), sc(m);
  for (int i = 1; i <= n; i++) {
    scanf("%s", sb[i] + 1);
    for (int j = 1; j <= m; j++) ss[i][j] = sb[i][j] - 'a' + 1;
  }
  for (long long i = 1; i <= n; i++) {
    for (long long l = 1; l <= m; l++) {
      memset(cnt, 0, sizeof(cnt));
      long long ass = 0;
      for (long long r = l; r <= m; r++) {
        ++cnt[ss[i][r]];
        if (cnt[ss[i][r]] & 1)
          ++ass;
        else
          --ass;
        if (ass <= 1)
          h[i][l][r] = gethash();
        else
          h[i][l][r] = -i * 10000 * l * r;
      }
    }
  }
  long long ans = 0;
  for (int l = 1; l <= m; l++) {
    for (int r = l; r <= m; r++) {
      ans += solve(l, r);
    }
  }
  printf("%lld\n", ans);
  return 0;
}
