#include <bits/stdc++.h>
using namespace std;
const int bas = 23333;
const long long mod = 9999999999973ll;
int N, M, S[26], L[555];
char C[255][255];
long long H[26], W[255][255][255], G[555];
int manacher(int n) {
  int k = 0, m = 0, res = 0;
  memset(L, 0, sizeof(L));
  for (int i = 1; i <= n; i++) {
    if (G[i] == -1) {
      continue;
    }
    int l = (m > i) ? min(L[2 * k - i], m - i) : 1;
    while (G[i - l] != -1 && G[i + l] != -1 && G[i - l] == G[i + l]) {
      l++;
    }
    if (l + i > m) {
      m = l + i;
      k = i;
    }
    L[i] = l;
    res += l;
  }
  return (res - N - 1) >> 1;
}
int main() {
  scanf("%d%d\n", &N, &M);
  long long h = 1;
  for (int i = 0; i < 26; i++) {
    h = h * bas % mod;
    H[i] = h;
  }
  for (int i = 1; i <= N; i++) {
    scanf("%s", C[i] + 1);
    for (int j = 1; j <= M; j++) {
      C[i][j] -= 'a';
      W[i][j][j] = H[C[i][j]];
      for (int k = j - 1; k > 0; k--) {
        W[i][k][j] = W[i][k + 1][j] + H[C[i][k]];
        if (W[i][k][j] >= mod) {
          W[i][k][j] -= mod;
        }
      }
      memset(S, 0, sizeof(S));
      int cnt = 0;
      for (int k = j; k > 0; k--) {
        S[C[i][k]]++;
        if (S[C[i][k]] & 1) {
          cnt++;
        } else {
          cnt--;
        }
        if (cnt > 1) {
          W[i][k][j] = -1;
        }
      }
    }
  }
  long long ANS = 0;
  for (int j = 1; j <= M; j++) {
    for (int k = j; k <= M; k++) {
      memset(G, 0, sizeof(G));
      G[0] = -1;
      G[(N + 1) << 1] = -1;
      for (int i = 1; i <= N; i++) {
        G[i << 1] = W[i][j][k];
      }
      ANS += manacher((N << 1) | 1);
    }
  }
  printf("%lld", ANS);
  return 0;
}
