#include <bits/stdc++.h>
using namespace std;
const int MAXN = 255;
const long long p = 33;
const long long mod = 1e9 + 7;
int n, m;
int mask[MAXN][MAXN];
int cnt[MAXN][MAXN][26];
long long power[MAXN], sum_power[MAXN];
string M[MAXN];
int manacher(const vector<pair<long long, bool>> &v) {
  auto get = [&](int i) {
    if (i & 1) return v[(i - 1) >> 1].first;
    return -1LL;
  };
  auto eq = [&](int i, int j) {
    bool a, b;
    a = b = true;
    if (i & 1) a = v[(i - 1) >> 1].second;
    if (j & 1) b = v[(j - 1) >> 1].second;
    return a & b & get(i) == get(j);
  };
  vector<int> len(2 * v.size() + 1, 0);
  int l, r;
  l = -1;
  r = -1;
  for (int i = 0; i < len.size(); i++) {
    int k = 0;
    if (r >= i) {
      int m = (l + r) >> 1;
      k = min(len[m - (i - m)], r - i + 1);
    }
    while (i + k < len.size() && i - k >= 0 && eq(i + k, i - k)) {
      k++;
    }
    len[i] = k;
    if (i + k - 1 >= r) {
      r = i + k - 1;
      l = i - k + 1;
    }
  }
  int ans = 0;
  for (int i = 0; i < len.size(); i++) {
    ans += (len[i] >> 1);
  }
  return ans;
}
long long get_hash(int i, int l, int r) {
  long long x = 1;
  long long h = 0;
  for (int c = 0; c < 26; c++) {
    long long k = cnt[i][r][c] - cnt[i][l - 1][c];
    if (k == 0) continue;
    long long xp = sum_power[k - 1] * x % mod;
    long long aux = c * xp % mod;
    h = (h + aux) % mod;
    x = x * power[k] % mod;
  }
  return h;
}
int solve() {
  int ans = 0;
  for (int l = 0; l < m; l++) {
    for (int r = l; r <= m - 1; r++) {
      vector<pair<long long, bool>> v(n);
      for (int i = 0; i < n; i++) {
        v[i].first = get_hash(i, l + 1, r + 1);
        v[i].second = __builtin_popcount(mask[i][r + 1] ^ mask[i][l]) <= 1;
      }
      ans += manacher(v);
    }
  }
  return ans;
}
int main() {
  ;
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  power[0] = sum_power[0] = 1;
  for (int i = 1; i <= MAXN - 1; i++) {
    power[i] = p * power[i - 1] % mod;
    sum_power[i] = (sum_power[i - 1] + power[i]) % mod;
  }
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    cin >> M[i];
    for (int j = 1; j <= m; j++) {
      mask[i][j] = mask[i][j - 1];
      mask[i][j] ^= (1 << (M[i][j - 1] - 'a'));
      for (int k = 0; k < 26; k++) cnt[i][j][k] = cnt[i][j - 1][k];
      cnt[i][j][M[i][j - 1] - 'a']++;
    }
  }
  cout << solve() << '\n';
  return 0;
}
