#include <bits/stdc++.h>
using namespace std;
const int inf = 0x3f3f3f3f;
const int mod = 1e7 + 7;
const int N = 500;
const double eps = 1e-10;
const double pi = acos(-1.0);
int mp[N * 2];
char g[N][N];
int cnt[2 * N][26];
int vis[N];
int check(int a, int b) {
  if (vis[a] > 1 || vis[b] > 1) return 0;
  for (int i = 0; i < 26; i++) {
    if (cnt[a][i] != cnt[b][i]) return 0;
  }
  return 1;
}
long long Manacher(int len) {
  long long cnt = 0;
  int mx = 0, id = 0;
  mp[0] = 0;
  for (int i = 1; i <= len; i++) {
    mp[i] = mx > i ? min(mp[2 * id - i], mx - i) : 1;
    while (check(i - mp[i], i + mp[i]) && i - mp[i] >= 0 &&
           i + mp[i] <= len + 1)
      mp[i]++;
    if (vis[i] > 1) mp[i] = 1;
    if (i + mp[i] > mx) {
      mx = i + mp[i];
      id = i;
    }
    cnt += 1LL * mp[i] / 2;
  }
  return cnt;
}
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) cin >> g[i][j];
  }
  long long ans = 0;
  for (int l = 1; l <= m; l++) {
    for (int i = 1; i <= n; i++) {
      for (int k = 0; k < 26; k++) {
        cnt[2 * i - 1][k] = vis[2 * i - 1] = 0;
      }
    }
    for (int r = l; r <= m; r++) {
      for (int i = 1; i <= n; i++) {
        cnt[2 * i - 1][g[i][r] - 'a']++;
        if (cnt[2 * i - 1][g[i][r] - 'a'] & 1)
          vis[2 * i - 1]++;
        else
          vis[2 * i - 1]--;
      }
      ans += Manacher(2 * n);
    }
  }
  printf("%lld\n", ans);
  return 0;
}
