#include <bits/stdc++.h>
using namespace std;
char a[260][260];
int ton[260][30], ji[260], mi[260], ha[260], s[260 << 2], pal[260 << 1];
int manacher(int n) {
  for (int i = n; i; -- --i) {
    s[i] = s[i >> 1];
    s[i - 1] = 0x3f3f3f3f;
  }
  int maxr = 0, mid = 0, ans = 0;
  for (int i = 1; i <= n; ++i) {
    if (s[i] < 0) continue;
    if (i < maxr)
      pal[i] = min(pal[(mid << 1) - i], maxr - i);
    else
      pal[i] = 1;
    while (s[i + pal[i]] == s[i - pal[i]]) ++pal[i];
    if (i + pal[i] > maxr) maxr = i + pal[i], mid = i;
    ans += pal[i] >> 1;
  }
  return ans;
}
int main() {
  s[0] = 0x3f3f3f3f;
  int n, m, ans = 0;
  scanf("%d%d", &n, &m);
  s[n << 1 | 1] = 0x3f3f3f3f;
  for (int i = 1; i <= n; ++i) scanf("%s", a[i] + 1);
  mi[0] = 1;
  for (int i = 1; i <= 30; ++i) mi[i] = 1ll * mi[i - 1] * 133 % 1000000009;
  for (int i = 1; i <= m; ++i) {
    memset(ton, 0, sizeof(ton));
    memset(ji, 0, sizeof(ji));
    memset(ha, 0, sizeof(ha));
    for (int j = i; j <= m; ++j) {
      for (int l = 1; l <= n; ++l) {
        int c = a[l][j] - 'a' + 1;
        ha[l] += mi[c];
        ha[l] >= 1000000009 ? ha[l] -= 1000000009 : 0;
        ++ton[l][c];
        ji[l] += (ton[l][c] & 1) ? 1 : -1;
        s[l] = (ji[l] > 1) ? -l : ha[l];
      }
      ans += manacher(n << 1);
    }
  }
  printf("%d", ans);
  return 0;
}
