#include <bits/stdc++.h>
using namespace std;
int n, m, ans;
int l[255 * 2], r[255 * 2], str[255 * 2], po[27];
char s[255][255];
int solve(int bas, int son) {
  int tot = 0;
  l[bas - 1] = bas;
  r[bas - 1] = bas - 1;
  for (int i = bas; i <= son; i++) {
    if (r[i - 1] < i) {
      l[i] = r[i] = i;
    } else {
      int sm = l[i - 1] + r[i - 1] - i;
      l[i] = i - min(sm - l[sm], sm - l[i - 1]);
      r[i] = 2 * i - l[i];
    }
    while (r[i] + 1 <= son && l[i] - 1 >= bas && str[l[i] - 1] == str[r[i] + 1])
      r[i]++, l[i]--;
    if (str[i] == 0)
      tot += (r[i] - l[i]) / 4;
    else
      tot += (r[i] - l[i] + 2) / 4;
  }
  return tot;
}
int main() {
  scanf("%d %d", &n, &m);
  for (int i = 1; i <= n; i++) scanf("%s", s[i] + 1);
  po[0] = 1;
  for (int i = 1; i < 26; i++) po[i] = 1ll * po[i - 1] * 701 % 1000000007;
  for (int i = 1; i <= m; i++) {
    int hash[255] = {0}, tot[255] = {0};
    bitset<26> odd[255];
    for (int j = i; j <= m; j++) {
      vector<pair<int, int> > v;
      for (int k = 1; k <= n; k++) {
        hash[k] = (hash[k] + po[s[k][j] - 'a']) % 1000000007;
        tot[k] -= odd[k].test(s[k][j] - 'a');
        odd[k][s[k][j] - 'a'] = !odd[k][s[k][j] - 'a'];
        tot[k] += odd[k].test(s[k][j] - 'a');
        v.push_back({hash[k], k});
      }
      sort(v.begin(), v.end());
      int cnt = 0;
      for (int k = 0; k < n; k++) {
        ++cnt;
        str[v[k].second * 2 - 1] = cnt;
        while (k + 1 < n && v[k].first == v[k + 1].first) {
          k++;
          str[v[k].second * 2 - 1] = cnt;
        }
      }
      for (int k = 1; k <= n; k++) {
        if (tot[k] > 1) continue;
        int bas = k;
        while (k + 1 <= n && tot[k + 1] < 2) k++;
        ans += solve((bas - 1) * 2, k * 2);
      }
    }
  }
  printf("%d", ans);
}
