#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 7;
const int mod = 1e9 + 7;
const double pi = acos(-1);
inline long long read() {
  long long x = 0, f = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  return x * f;
}
long long ans;
int cc[300][26], vis[300];
long long has[30];
long long gt[555], pp[555], tmp[300], cnt[300];
int p[555];
char s[300][300];
int n, m;
long long ma() {
  memset(p, 0, sizeof p);
  gt[0] = -2;
  for (int i = 1; i <= n; i++)
    gt[2 * i - 1] = -1, gt[2 * i] = tmp[i], pp[2 * i] = vis[i],
               pp[2 * i - 1] = 1;
  int le = n * 2 + 1;
  gt[le] = -1, pp[le] = 1;
  int mx = 0, pos = 0;
  for (int i = 1; i <= le; i++) {
    if (mx > i)
      p[i] = min(mx - i, p[2 * pos - i]);
    else
      p[i] = 1;
    while (i - p[i] > 0 && i + p[i] <= le && gt[i + p[i]] == gt[i - p[i]] &&
           pp[i + p[i]] && pp[i - p[i]])
      p[i]++;
    if (i + p[i] > mx) mx = i + p[i], pos = i;
  }
  long long res = 0;
  for (int i = 1; i <= le; i++) {
    if (!pp[i]) continue;
    res += p[i] - (p[i] + 1) / 2;
  }
  return res;
}
int main() {
  n = read();
  m = read();
  has[0] = 1ll;
  for (int i = 1; i <= 26; i++) {
    has[i] = has[i - 1] * 233 % mod;
  }
  for (int i = 1; i <= n; i++) scanf("%s", s[i] + 1);
  for (int i = 1; i <= m; i++) {
    memset(cnt, 0, sizeof cnt);
    memset(tmp, 0, sizeof tmp);
    for (int j = 1; j <= n; j++) memset(cc, 0, sizeof(cc));
    for (int j = i; j <= m; j++) {
      for (int k = 1; k <= n; k++) {
        int pp = s[k][j] - 'a';
        if (cc[k][pp] & 1)
          cnt[k]--;
        else
          cnt[k]++;
        vis[k] = (cnt[k] <= 1);
        cc[k][pp]++;
        (tmp[k] += has[pp]) % mod;
      }
      ans += ma();
    }
  }
  cout << ans << "\n";
}
