#include <bits/stdc++.h>
using namespace std;
int n, m;
char s[255][255];
int sum[255][255];
unsigned long long Has[255][255], val[30], arr[255];
int len[255];
int main() {
  scanf("%d%d", &n, &m);
  srand(n * m);
  rand(), rand();
  for (int i = 0; i < 26; i++) val[i] = rand() << 15 | rand();
  for (int i = 1; i <= n; i++) {
    scanf("%s", s[i] + 1);
    for (int j = 1; j <= m; j++) {
      sum[i][j] = 1 << (s[i][j] - 'a');
      sum[i][j] ^= sum[i][j - 1];
      Has[i][j] = (val[s[i][j] - 'a'] + Has[i][j - 1]) & ((1ll << 60) - 1);
    }
  }
  unsigned long long ans = 0;
  for (int a = 1; a <= m; a++)
    for (int b = a; b <= m; b++) {
      int cnt = 1;
      for (int i = 1; i <= n; i++) {
        arr[i << 1 | 1] = ((1ll << 60) - 1) + 1;
        if (__builtin_popcount(sum[i][b] ^ sum[i][a - 1]) <= 1)
          arr[i << 1] = (Has[i][b] - Has[i][a - 1]) & ((1ll << 60) - 1);
        else
          arr[i << 1] = ((1ll << 60) - 1) + (++cnt);
      }
      arr[0] = ((1ll << 60) - 1) + (++cnt),
      arr[(n + 1) << 1] = ((1ll << 60) - 1) + (++cnt);
      arr[1] = ((1ll << 60) - 1) + 1;
      int mx = 0, o = 0;
      for (int i = 1; i <= (n << 1); i++) {
        if (mx > i)
          len[i] = min(len[2 * o - i], mx - i);
        else
          len[i] = 1;
        for (; arr[i + len[i]] == arr[i - len[i]];) len[i]++;
        if (i + len[i] > mx) mx = i + len[i], o = i;
        if (arr[i] <= ((1ll << 60) - 1) + 1) ans += len[i] / 2;
      }
    }
  cout << ans << endl;
}
