#include <bits/stdc++.h>
using namespace std;
const int MAXN = 250;
char mmp[MAXN + 5][MAXN + 5];
int a[MAXN << 1 + 5][26], tot[MAXN << 1 + 5];
int n, m;
long long ans;
bool cmp(int x, int y) {
  if (tot[x] > 1 || tot[y] > 1) return false;
  for (int i = 0; i < 26; i++) {
    if (a[x][i] != a[y][i]) {
      return false;
    }
  }
  return true;
}
long long p[MAXN * 2 + 5];
int manacher() {
  int i;
  int len = n;
  len++;
  len <<= 1;
  long long ret = 0, mx = 0, id = 0;
  for (i = 1; i < len; i++) {
    if (mx > i)
      p[i] = min(p[id * 2 - i], mx - i);
    else
      p[i] = 1;
    int o = i;
    while (i - p[i] > 0 && i + p[i] < len && cmp(i - p[i], i + p[i])) {
      p[i]++;
      o++;
    }
    if (tot[i] > 1) p[i] = 1;
    if (mx < p[i] + i) mx = p[i] + i, id = i;
    ret = max(ret, p[i]);
    ans += (p[i]) / 2;
  }
  return ret - 1;
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 0; i < n; i++) scanf("%s", mmp[i]);
  for (int i = 0; i < m; i++) {
    for (int j = 0; j < n; j++) {
      for (int k = 0; k < 26; k++) {
        a[(j + 1) << 1][k] = tot[(j + 1) << 1] = 0;
      }
    }
    for (int j = i; j < m; j++) {
      for (int k = 0; k < n; k++) {
        if (a[(k + 1) << 1][mmp[k][j] - 'a'] & 1)
          tot[(k + 1) << 1]--;
        else
          tot[(k + 1) << 1]++;
        a[(k + 1) << 1][mmp[k][j] - 'a']++;
      }
      manacher();
    }
  }
  printf("%lld\n", ans);
}
