#include <bits/stdc++.h>
using namespace std;
const int iinf = 0x3f3f3f3f;
const long long linf = 0x3f3f3f3f3f3f3f3f;
const int N = 250;
const int B = 998244353, mod = 1e9 + 7;
int n, m, a[N][N], sum[N];
int hsh[N], base[26];
long long ans = 0;
bool ok(int s) { return s == 0 || s == (s & -s); }
const int T = (N << 1) + 3;
int ma[T], ss[T];
int get(int *s, int len) {
  int res = 0;
  fill(ma, ma + len * 2 + 3, 0);
  ss[0] = -1123;
  for (int i = (1), I = (len * 2 + 2); i < I; i++)
    ss[i] = (i & 1) ? -3917 : s[(i >> 1) - 1];
  ss[len * 2 + 2] = -5119;
  int now = 0, mid = 0;
  for (int i = (1), I = (len * 2 + 2); i < I; i++) {
    if (i <= now) ma[i] = min(ma[(mid << 1) - i], now - i + 1);
    while (ss[i - ma[i]] == ss[i + ma[i]]) ma[i]++;
    if (now < i + ma[i]) now = i + ma[i] - 1, mid = i;
  }
  for (int i = (1), I = (len * 2 + 2); i < I; i++) res += (ma[i] >> 1);
  return res;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0), cout.tie(0);
  cin >> n >> m;
  for (int i = (0), I = (n); i < I; i++) {
    string s;
    cin >> s;
    for (int j = (0), I = (m); j < I; j++) a[i][j] = s[j] - 'a';
  }
  base[0] = 1;
  for (int i = (1), I = (26); i < I; i++) base[i] = 1ll * base[i - 1] * B % mod;
  for (int l = (0), I = (m); l < I; l++) {
    fill(sum, sum + n, 0);
    fill(hsh, hsh + n, 0);
    for (int r = (l), I = (m); r < I; r++) {
      int hsm = 0, lst = 0;
      for (int i = (0), I = (n); i < I; i++) {
        sum[i] ^= (1 << a[i][r]);
        (hsh[i] += base[a[i][r]]) %= mod;
        if (!ok(sum[i])) ans += get(hsh + lst, i - lst), lst = i + 1;
      }
      ans += get(hsh + lst, n - lst);
    }
  }
  cout << ans << '\n';
  return 0;
}
