#include <bits/stdc++.h>
char mat[257][257];
int counts[257]['z' - 'a' + 1];
int npcounts[257];
int tre[257];
int main() {
  int n, m;
  scanf("%i %i", &n, &m);
  for (int i = 1; i <= n; i++) scanf("%s", &mat[i][1]);
  int ret = 0;
  for (int s = 1; s <= m; s++) {
    memset(counts, 0, sizeof(counts));
    memset(npcounts, 0, sizeof(npcounts));
    counts[0][0] = 1337133713;
    counts[n + 1][0] = 1337133714;
    for (int e = s; e <= m; e++) {
      ;
      ;
      for (int i = 1; i <= n; i++) {
        if ((++counts[i][mat[i][e] - 'a']) % 2 == 1) {
          npcounts[i]++;
        } else {
          npcounts[i]--;
        }
      }
      int ki = 0;
      int kend = 0;
      for (int i = 1; i <= n; i++) {
        tre[i] = 0;
        if (npcounts[i] > 1) {
          ;
          ;
          continue;
        }
        if (i < kend) tre[i] = std::min(tre[ki - (i - ki)], kend - i);
        while (npcounts[i + tre[i]] <= 1 &&
               memcmp(counts[i + tre[i]], counts[i - tre[i]],
                      sizeof(int['z' - 'a' + 1])) == 0) {
          tre[i]++;
        }
        if (i + tre[i] > kend) {
          ki = i;
          kend = i + tre[i];
        };
        ;
        ret += tre[i];
      };
      ;
      ki = 0;
      kend = 0;
      for (int i = 1; i < n; i++) {
        tre[i] = 0;
        ;
        ;
        if (i < kend) tre[i] = std::min(tre[ki - (i - ki)], kend - i - 1);
        while (npcounts[i + 1 + tre[i]] <= 1 &&
               memcmp(counts[i + 1 + tre[i]], counts[i - tre[i]],
                      sizeof(int['z' - 'a' + 1])) == 0) {
          tre[i]++;
        }
        if (i + tre[i] + 1 > kend) {
          ki = i;
          kend = i + tre[i] + 1;
        };
        ;
        ret += tre[i];
      };
      ;
    }
  }
  printf("%i\n", ret);
  return 0;
}
