#include <bits/stdc++.h>
using namespace std;
const int N = 252;
int n, m, first[N][26], d1[N], d2[N];
char a[N][N];
bool equal(int i, int j) {
  for (int k = 0; k <= 25; ++k)
    if (first[i][k] != first[j][k]) return false;
  return true;
}
long long manacher(int a, int n) {
  long long ret = 0;
  for (int i = 0; i <= n - 1; ++i) d1[i] = d2[i] = a;
  for (int i = a, l = a, r = -1; i < n; i++) {
    int k = (i > r) ? 1 : min(d1[l + r - i], r - i);
    while (0 <= i - k && i + k < n && equal(i - k, i + k)) {
      k++;
    }
    ret += d1[i] = k--;
    if (i + k > r) {
      l = i - k;
      r = i + k;
    }
  }
  for (int i = a, l = a, r = -1; i < n; i++) {
    int k = (i > r) ? 0 : min(d2[l + r - i + 1], r - i + 1);
    while (0 <= i - k - 1 && i + k < n && equal(i - k - 1, i + k)) {
      k++;
    }
    ret += d2[i] = k--;
    if (i + k > r) {
      l = i - k - 1;
      r = i + k;
    }
  }
  return ret;
}
bool palin(int k) {
  int odd = 0;
  for (int i = 0; i <= 25; ++i) odd += first[k][i] & 1;
  return odd < 2;
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 0; i <= n - 1; ++i) scanf("%s", a[i]);
  long long ans = 0;
  for (int i = 0; i <= m - 1; ++i) {
    memset(first, 0, sizeof first);
    for (int j = i; j <= m - 1; ++j) {
      int last = -1;
      for (int k = 0; k <= n - 1; ++k) {
        ++first[k][a[k][j] - 'a'];
        if (!palin(k)) {
          if (~last) ans += manacher(last, k);
          last = -1;
        } else if (last == -1)
          last = k;
      }
      if (~last) ans += manacher(last, n);
    }
  }
  cout << ans;
}
