#include <bits/stdc++.h>
using namespace std;
const int N = (int)257;
int mod = (int)1e9 + 87;
int p = 997;
int mult(int a, int b) { return (a * 1LL * b) % mod; }
int add(int a, int b) { return (a + b) % mod; }
int cnt[N][26];
int n, m;
int a[N][N];
int pw[N], h[N], mask[N];
void precalc() {
  pw[0] = 1;
  for (int i = 1; i < N; i++) {
    pw[i] = mult(pw[i - 1], p);
  }
}
bool isgood(int x) { return x == 0 || (x & (x - 1)) == 0; }
int b[N];
int solve(int tl, int tr) {
  int siz = 0;
  int ans = 0;
  for (int i = tl; i <= tr; i++) {
    b[siz++] = h[i];
  }
  vector<int> d(siz);
  int l = 0;
  int r = -1, k;
  for (int i = 0; i < siz; i++) {
    k = 1;
    if (i <= r) {
      k = min(d[l + r - i], r - i);
    }
    while (0 <= i - k && i + k < siz && b[i - k] == b[i + k]) k++;
    d[i] = k;
    ans += k;
    if (i + k - 1 > r) {
      r = i + k - 1;
      l = i - k + 1;
    }
  }
  l = 0;
  r = -1;
  for (int i = 0; i < siz; i++) {
    k = 0;
    if (i <= r) {
      k = min(d[l + r - i + 1], r - i + 1);
    }
    while (0 <= i - k - 1 && i + k < siz && b[i - k - 1] == b[i + k]) k++;
    d[i] = k;
    ans += k;
    if (i + k - 1 > r) {
      r = i + k - 1;
      l = i - k;
    }
  }
  return ans;
}
int main() {
  precalc();
  scanf("%d %d", &n, &m);
  string s;
  long long ans = 0;
  for (int i = 1; i <= n; i++) {
    cin >> s;
    for (int j = 1; j <= m; j++) {
      a[i][j] = (s[j - 1] - 'a' + 1);
    }
  }
  for (int l = 1; l <= m; l++) {
    for (int i = 1; i <= n; i++) {
      memset(cnt[i], 0, sizeof cnt[i]);
      h[i] = 0;
      mask[i] = 0;
    }
    for (int r = l; r <= m; r++) {
      for (int i = 1; i <= n; i++) {
        if (cnt[i][a[i][r]]) {
          h[i] = add(h[i], mod - mult(cnt[i][a[i][r]], pw[26 - a[i][r] + 1]));
        }
        cnt[i][a[i][r]]++;
        h[i] = add(h[i], mult(cnt[i][a[i][r]], pw[26 - a[i][r] + 1]));
        mask[i] ^= (1 << a[i][r]);
      }
      int i1 = 1, i2;
      while (i1 <= n) {
        if (!isgood(mask[i1])) {
          i1++;
          continue;
        }
        i2 = i1;
        while (i2 <= n && isgood(mask[i2])) {
          i2++;
        }
        i2--;
        int prev = ans;
        ans += solve(i1, i2);
        i1 = i2 + 1;
      }
    }
  }
  cout << ans;
}
