#include <bits/stdc++.h>
using namespace std;
inline long long read() {
  long long x = 0;
  bool f = 1;
  char s = getchar();
  while ((s < '0' || s > '9') && s > 0) {
    if (s == '-') f ^= 1;
    s = getchar();
  }
  while (s >= '0' && s <= '9') x = (x << 1) + (x << 3) + s - '0', s = getchar();
  return f ? x : -x;
}
int n, m, ma[255 << 1], num[255][30];
int nj[255];
bool ok[255 << 1];
char s[255][255];
long long ans, x[255 << 1], y[255 << 1], ch1[30], ch2[30];
inline void Manacher() {
  memset(ma, 0, sizeof(ma));
  for (int i = 1, r = 0, mid = 0, N = (n << 1) + 1; i <= N; i++) {
    if (i <= r) ma[i] = min(ma[(mid << 1) - i], r - i + 1);
    while (ok[i + ma[i]] && ok[i - ma[i]] && x[i + ma[i]] == x[i - ma[i]] &&
           y[i + ma[i]] == y[i - ma[i]])
      ma[i]++;
    if (i + ma[i] - 1 > r) r = i + ma[i] - 1, mid = i;
    if (ok[i]) ans += (ma[i] >> 1);
  }
}
inline long long ksm(long long a, long long b, long long mo) {
  long long res = 1;
  for (; b; b >>= 1) {
    if (b & 1) res = res * a % mo;
    a = a * a % mo;
  }
  return res;
}
int main() {
  x[0] = -1, y[1] = -1, ch1[0] = ch2[0] = 1;
  for (int i = 1; i < 26; i++) ch1[i] = (ch1[i - 1] << 8) % 1000000007ll;
  for (int i = 1; i < 26; i++) ch2[i] = (ch2[i - 1] << 8) % 998244353ll;
  n = read(), m = read();
  memset(ok, 1, sizeof(ok));
  for (int i = 1; i <= n; i++) y[(i << 1) + 1] = -1;
  for (int i = 1; i <= n; i++) scanf("%s", s[i] + 1);
  for (int l = 1; l <= m; l++) {
    for (int i = 1; i <= n; i++)
      x[i << 1] = y[i << 1] = 0, nj[i] = 0, ok[i << 1] = 1;
    for (int i = 1; i <= n; i++) memset(num[i], 0, sizeof(num[i]));
    for (int r = l; r <= m; r++) {
      for (int i = 1; i <= n; i++) {
        int u = s[i][r] - 'a';
        num[i][u]++;
        x[i << 1] = (ch1[u] + x[i << 1]) % 1000000007ll;
        y[i << 1] = (ch2[u] + y[i << 1]) % 998244353ll;
        if (num[i][u] & 1)
          nj[i]++;
        else
          nj[i]--;
        if (nj[i] < 2)
          ok[i << 1] = 1;
        else
          ok[i << 1] = 0;
      }
      Manacher();
    }
  }
  printf("%lld\n", ans);
  return 0;
}
