#include <bits/stdc++.h>
using namespace std;
const int N = 255;
int s[N * 2][N][26];
int d[N * 2];
bool flag[N * 2];
bool check(int a, int l, int r) {
  int cur = 0;
  for (int i = 0; i <= 25; i++)
    if ((s[a][r][i] - s[a][l - 1][i]) % 2 == 1) {
      cur++;
      if (cur > 1) return false;
    }
  return true;
}
bool cmp(int a, int b, int l, int r) {
  for (int i = 0; i <= 25; i++)
    if (s[a][r][i] - s[a][l - 1][i] != s[b][r][i] - s[b][l - 1][i])
      return false;
  return true;
}
int main() {
  int n, m;
  cin >> n >> m;
  for (int i = 1; i <= n; i++) {
    char a[N];
    scanf("%s", a + 1);
    for (int j = 1; j <= m; j++) {
      for (int c = 0; c < 26; c++) s[i * 2][j][c] = s[i * 2][j - 1][c];
      s[i * 2][j][a[j] - 'a']++;
    }
  }
  n = n * 2 + 1;
  int ans = 0;
  for (int i = 1; i <= m; i++)
    for (int j = i; j <= m; j++) {
      for (int k = 1; k <= n; k++)
        if (check(k, i, j)) {
          d[k] = 1;
          flag[k] = true;
        } else {
          flag[k] = false;
          d[k] = 0;
        }
      int maxr = 0, p = 0;
      for (int k = 2; k <= n; k++) {
        if (maxr >= k) d[k] = min(d[maxr + p - k], maxr - k + 1);
        while (d[k] + k <= n && k - d[k] >= 1 && flag[d[k] + k] &&
               flag[k - d[k]] && cmp(d[k] + k, k - d[k], i, j))
          d[k]++;
        if (k + d[k] - 1 > maxr) {
          maxr = k + d[k] - 1;
          p = k - d[k] + 1;
        }
      }
      for (int i = 1; i <= n; i++) ans += d[i] / 2;
    }
  printf("%d\n", ans);
  return 0;
}
