#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using lll = __int128;
template <typename T>
using v = vector<T>;
const ll N = 250;
const ll V = 26;
const ll P[2] = {(ll)1e9 + 7, (ll)1e9 + 9};
const ll C[2] = {251, 257};
ll arr[N][N];
ll counts[N][N][V];
ll seq[N][V];
ll pows[2][V];
lll keys[N];
ll matchlen[N + 1];
bool pal[N];
int main(int argc, char const* argv[]) {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  ll n, m;
  cin >> n >> m;
  pows[0][0] = 1;
  pows[1][0] = 1;
  for (ll v = 1; v < V; v++) {
    pows[0][v] = (pows[0][v - 1] * C[0]) % P[0];
    pows[1][v] = (pows[1][v - 1] * C[1]) % P[1];
  }
  for (ll i = 0; i < n; i++) {
    for (ll j = 0; j < m; j++) {
      char cur;
      cin >> cur;
      arr[i][j] = cur - 'a';
    }
  }
  for (ll i = 0; i < n; i++) {
    for (ll j = 0; j < m; j++) {
      for (ll k = 0; k < V; k++) {
        counts[i][j][k] = j > 0 ? counts[i][j - 1][k] : 0;
      }
      ll cur = arr[i][j];
      counts[i][j][cur]++;
    }
  }
  ll result = 0;
  for (ll j1 = 0; j1 < m; j1++) {
    for (ll j0 = 0; j0 <= j1; j0++) {
      for (ll i = 0; i < n; i++) {
        ll oddcount = 0;
        for (ll v = 0; v < V; v++) {
          seq[i][v] = counts[i][j1][v] - ((j0 > 0) ? counts[i][j0 - 1][v] : 0);
          oddcount += seq[i][v] & 1;
        }
        pal[i] = (oddcount < 2);
      }
      for (ll i = 0; i < n; i++) {
        ll hash0 = 0, hash1 = 0;
        for (ll v = 0; v < V; v++) {
          hash0 += seq[i][v] * pows[0][v];
          hash1 += seq[i][v] * pows[1][v];
        }
        keys[i] = hash0 + (((lll)hash1) << 64);
      }
      ll l = 0, r = -1;
      for (ll i = 0; i < n; i++) {
        ll j = (i <= r) ? min(matchlen[l + r - i], r + 1 - i) : 0;
        ll mj = min(i + 1, n - i);
        for (; j <= mj - 1 && pal[i + j] && pal[i - j] &&
               keys[i + j] == keys[i - j];
             j++) {
        }
        matchlen[i] = j;
        if (i + (j - 1) > r) {
          r = i + (j - 1);
          l = i - (j - 1);
        }
        result += matchlen[i];
      }
      l = 0, r = -1;
      for (ll i = 0; i <= n; i++) {
        ll j = (i < r) ? min(matchlen[l + r - i], r - i) : 0;
        ll mj = min(i, n - i);
        for (; j <= mj - 1 && pal[i + j] && pal[i - j - 1] &&
               keys[i + j] == keys[i - j - 1];
             j++) {
        }
        matchlen[i] = j;
        if (i + j > r) {
          r = i + j;
          l = i - j;
        }
        result += matchlen[i];
      }
    }
  }
  cout << result << "\n";
  return 0;
}
