#include <bits/stdc++.h>
using namespace std;
inline int readint() {
  int a = 0;
  char c = getchar(), f = 1;
  for (; c < '0' || c > '9'; c = getchar())
    if (c == '-') f = -f;
  for (; '0' <= c && c <= '9'; c = getchar())
    a = (a << 3) + (a << 1) + (c ^ 48);
  return a * f;
}
const int MaxN = 252;
struct Node {
  int a[26];
  int bad;
  void add(char s) {
    ++a[s - 'a'];
    if (a[s - 'a'] & 1)
      ++bad;
    else
      --bad;
  }
  void clear() { memset(a, 0, 26 << 2), bad = 0; }
  bool operator==(const Node &t) const {
    if (bad > 1 || t.bad > 1) return false;
    for (int i = 0; i < 26; ++i)
      if (a[i] != t.a[i]) return false;
    return true;
  }
};
Node a[MaxN];
char maze[MaxN][MaxN];
int r[MaxN << 1];
int main() {
  int n = readint(), m = readint();
  for (int i = 1; i <= n; ++i) scanf("%s", maze[i] + 1);
  long long ans = 0;
  for (int L = 1; L <= m; ++L) {
    for (int i = 1; i <= n; ++i) a[i].clear();
    for (int R = L; R <= m; ++R) {
      for (int i = 1; i <= n; ++i) a[i].add(maze[i][R]);
      int p = 1;
      r[1] = 0;
      for (int i = 1; i <= n; ++i) {
        ;
        if ((i << 1) < p + r[p])
          r[i << 1] = min(p + r[p] - (i << 1), r[(p - i) << 1]);
        else
          r[i << 1] = 1;
        while ((i << 1) - r[i << 1] - 1 >= 2 &&
               (i << 1) + r[i << 1] + 1 <= 2 * n &&
               a[((i << 1) - r[i << 1] - 1) >> 1] ==
                   a[((i << 1) + r[i << 1] + 1) >> 1])
          r[i << 1] += 2;
        if (a[i].bad > 1) r[i << 1] = -1;
        if ((i << 1) + r[i << 1] > p + r[p]) p = i << 1;
        ans += (r[i << 1] + 1) >> 1;
        ;
        if ((i << 1 | 1) < p + r[p])
          r[i << 1 | 1] = min(p + r[p] - (i << 1 | 1), r[2 * p - (i << 1 | 1)]);
        else
          r[i << 1 | 1] = 0;
        while ((i << 1 | 1) - r[i << 1 | 1] - 1 >= 2 &&
               (i << 1 | 1) + r[i << 1 | 1] + 1 <= 2 * n &&
               a[((i << 1 | 1) - r[i << 1 | 1] - 1) >> 1] ==
                   a[((i << 1 | 1) + r[i << 1 | 1] + 1) >> 1])
          r[i << 1 | 1] += 2;
        if ((i << 1 | 1) + r[i << 1 | 1] > p + r[p]) p = i << 1 | 1;
        ans += r[i << 1 | 1] >> 1;
      }
    }
  }
  printf("%lld\n", ans);
  return 0;
}
