#include <bits/stdc++.h>
using namespace std;
template <typename T>
void read(T &x) {
  x = 0;
  int f = 1;
  char c = getchar();
  for (; !isdigit(c); c = getchar())
    if (c == '-') f = -1;
  for (; isdigit(c); c = getchar()) x = x * 10 + c - 48;
  x *= f;
}
long long pp[2] = {29, 31}, po[2][30];
struct hs {
  long long val[2];
};
bool operator==(hs x, hs y) {
  return (x.val[0] == y.val[0] && x.val[1] == y.val[1]);
}
hs operator-(hs x, hs y) {
  return (hs){x.val[0] - y.val[0], x.val[1] - y.val[1]};
}
hs rdval() {
  hs rt;
  rt.val[0] *= rand(), rt.val[0] += rand();
  rt.val[0] *= rand(), rt.val[0] += rand();
  rt.val[1] *= rand(), rt.val[1] += rand();
  rt.val[1] *= rand(), rt.val[1] += rand();
  return rt;
}
hs zo;
char s[260][260];
int n, m;
hs gin[510], nw[510];
int len[510];
void manacher() {
  int home = 0, p = 0;
  len[1] = 1;
  for (int i = 2; i <= n + n + 1; ++i) {
    len[i] = 1;
    if (i <= p) {
      int j = home * 2 - i;
      if (i + len[j] - 1 < p)
        len[i] = len[j];
      else {
        len[i] = p - i + 1;
        int l = i - len[i], r = i + len[i];
        while (gin[l] == gin[r] && l >= 1 && r <= n + n + 1) ++len[i], l--, r++;
        if (r - 1 > p) p = r - 1, home = i;
      }
    } else {
      int l = i - 1, r = i + 1;
      while (gin[l] == gin[r] && l >= 1 && r <= n + n + 1) ++len[i], l--, r++;
      if (r - 1 > p) p = r - 1, home = i;
    }
  }
}
int nwv[260][30], ji[260];
int main() {
  zo.val[0] = 0, zo.val[1] = 0;
  srand(time(0));
  read(n);
  read(m);
  for (int i = 1; i <= n; ++i) scanf("%s", s[i] + 1);
  for (int i = 1; i <= n + 1; ++i) gin[i * 2 - 1] = zo;
  po[0][0] = 1;
  po[1][0] = 1;
  for (int i = 1; i < 26; ++i)
    for (int j = 0; j < 2; ++j) po[j][i] = po[j][i - 1] * pp[j];
  long long ans = 0;
  for (int l = 1; l <= m; ++l) {
    memset(nwv, 0, sizeof(nwv));
    for (int i = 1; i <= n; ++i) nw[i] = zo;
    memset(ji, 0, sizeof(ji));
    for (int r = l; r <= m; ++r) {
      for (int i = 1; i <= n; ++i) {
        int pos = s[i][r] - 'a';
        ++nwv[i][pos];
        if (nwv[i][pos] & 1)
          ++ji[i];
        else
          --ji[i];
        nw[i].val[0] += po[0][pos];
        nw[i].val[1] += po[1][pos];
      }
      for (int i = 1; i <= n; ++i)
        if (ji[i] <= 1)
          gin[i * 2] = nw[i];
        else
          gin[i * 2] = rdval();
      manacher();
      for (int i = 2; i <= n + n; ++i)
        if ((i & 1) || ji[i / 2] <= 1) ans += len[i] / 2;
    }
  }
  cout << ans << endl;
  return 0;
}
