#include <bits/stdc++.h>
const int maxn = 257;
char map[maxn][maxn];
int n, m, str[maxn << 1], mask[maxn], e[maxn], ans;
struct Manacher {
  int p[maxn << 1];
  bool check(int x) { return x - (x & -x) == 0; }
  bool equal(int x, int y) {
    if ((x & 1) != (y & 1)) return false;
    return (x & 1) ||
           (check(mask[x >> 1]) && check(mask[y >> 1]) && str[x] == str[y]);
  }
  int solve(int len) {
    int max_right = 0, pos = 0, ret = 0;
    for (int i = 1; i <= len; i++) {
      p[i] = (max_right > i ? std::min(p[pos + pos - i], max_right - i) : 1);
      if ((i & 1) || check(mask[i >> 1])) {
        while (equal(i + p[i], i - p[i])) p[i]++;
        if (max_right < i + p[i]) pos = i, max_right = i + p[i];
        ret += p[i] / 2;
      } else
        p[i] = 2;
    }
    return ret;
  }
} manacher;
int main() {
  scanf("%d%d", &n, &m);
  str[0] = -1, str[n * 2 + 2] = -2, e[0] = 1;
  for (int i = 1; i <= 26; i++) e[i] = int(1ll * e[i - 1] * 257 % 19260817);
  for (int i = 1; i <= n; i++) scanf("%s", map[i] + 1);
  for (int l = 1; l <= m; l++) {
    for (int i = 1; i <= n; i++) mask[i] = str[i << 1] = 0;
    for (int r = l; r <= m; r++) {
      for (int i = 1; i <= n; i++) {
        mask[i] ^= (1 << (map[i][r] - 'a'));
        str[i << 1] = (str[i << 1] + e[map[i][r] - 'a' + 1]) % 19260817;
      }
      ans += manacher.solve(n << 1 | 1);
    }
  }
  printf("%d\n", ans);
  return 0;
}
