#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e6 + 50;
const long long mod = 1e9 + 7;
char s[1550][1550];
int num[1550][26];
int odd[1550];
bool cmp(int a, int b) {
  if (odd[a] > 1 || odd[b] > 1) return false;
  for (int i = 0; i < 26; i++)
    if (num[a][i] != num[b][i]) return false;
  return true;
}
int n, m;
int Mp[550];
int manacher() {
  memset(Mp, 0, sizeof(Mp));
  int mx = 0, id = 0;
  int ans = 0;
  for (int i = 0; i <= 2 * n + 1; i++) {
    Mp[i] = mx > i ? min(Mp[2 * id - i], mx - i) : 1;
    while (i - Mp[i] >= 0 && i + Mp[i] <= 2 * n + 1 &&
           cmp(i - Mp[i], i + Mp[i]))
      Mp[i]++;
    if (odd[i] > 1) Mp[i] = 1;
    if (i + Mp[i] > mx) mx = i + Mp[i], id = i;
    ans += Mp[i] / 2;
  }
  return ans;
}
int main() {
  std::ios::sync_with_stdio(false);
  cin >> n >> m;
  for (int i = 1; i <= n; i++) cin >> s[i] + 1;
  long long ans = 0;
  for (int i = 1; i <= m; i++) {
    for (int j = 0; j <= 2 * n + 50; j++) {
      for (int k = 0; k < 26; k++) num[j][k] = 0, odd[j] = 0;
    }
    odd[0] = 1e9;
    for (int j = i; j <= m; j++) {
      for (int k = 1; k <= n; k++) {
        num[2 * k][s[k][j] - 'a']++;
        if (num[2 * k][s[k][j] - 'a'] & 1)
          odd[2 * k]++;
        else
          odd[2 * k]--;
      }
      ans += manacher();
    }
  }
  cout << ans << endl;
  return 0;
}
