#include <bits/stdc++.h>
const int MAXN = 250;
char s[MAXN + 5][MAXN + 5];
int a[2 * MAXN + 5][26], tot[2 * MAXN + 5];
int len[2 * MAXN + 5];
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;
}
int main() {
  int n, m;
  long long ans = 0;
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) scanf("%s", s[i] + 1);
  for (int i = 1; i <= m; i++) {
    for (int j = 1; j <= n; j++)
      for (int k = 0; k < 26; k++) a[2 * j - 1][k] = tot[2 * j - 1] = 0;
    for (int j = i; j <= m; j++) {
      for (int k = 1; k <= n; k++) {
        if (a[2 * k - 1][s[k][j] - 'a'] & 1)
          tot[2 * k - 1]--;
        else
          tot[2 * k - 1]++;
        a[2 * k - 1][s[k][j] - 'a']++;
      }
      len[0] = 1;
      int mxpos = 0, mx = 0;
      for (int k = 1; k <= 2 * n; k++) {
        if (k <= mx) {
          int mk = 2 * mxpos - k;
          if (len[mk] < mx - k)
            len[k] = len[mk];
          else {
            int p = mx;
            while (p <= 2 * n && p <= 2 * k && cmp(2 * k - p, p)) p++;
            len[k] = p - k;
          }
        } else {
          int p = k;
          while (p <= 2 * n && p <= 2 * k && cmp(2 * k - p, p)) p++;
          len[k] = p - k;
        }
        if (k + len[k] - 1 > mx) {
          mx = k + len[k] - 1;
          mxpos = k;
        }
        ans += len[k] / 2;
      }
    }
  }
  printf("%I64d\n", ans);
}
