#include <bits/stdc++.h>
using namespace std;
const long long INF = 2e18;
const pair<long long, long long> diez = {1e9, 1e9};
int n, m, lit[255][30], OK[255];
char mat[255][255];
long long ans;
pair<long long, long long> h[255], p[255];
pair<long long, long long> v2[2 * 255];
int lg[2 * 255];
void solve(vector<pair<long long, long long> > &v) {
  int n = 0;
  for (auto it : v) {
    if (n == 0)
      v2[n++] = it;
    else
      v2[n++] = diez, v2[n++] = it;
  }
  int dr = 0, c = 0;
  for (int i = 0; i < n; i++) {
    int crt = 0;
    if (dr >= i) crt = min(lg[2 * c - i], dr - i);
    while (i - crt - 1 >= 0 && i + crt + 1 < n &&
           v2[i - crt - 1] == v2[i + crt + 1])
      crt++;
    lg[i] = crt;
    if (crt + i > dr) {
      dr = crt + i;
      c = i;
    }
    ans += crt / 2 + 1;
    if (i % 2 == 1 && crt % 2 == 0) ans--;
  }
}
int main() {
  ios::sync_with_stdio(false);
  cin >> n >> m;
  for (int i = 1; i <= n; i++) cin >> mat[i] + 1;
  p[0] = {1, 1};
  for (int i = 1; i <= 28; i++)
    p[i] = {p[i - 1].first * 257 % 998244853,
            p[i - 1].second * 257 % 1000000007};
  for (int l = 1; l <= m; l++) {
    memset(h, 0, sizeof(h));
    memset(lit, 0, sizeof(lit));
    memset(OK, 0, sizeof(OK));
    for (int r = l; r <= m; r++) {
      for (int i = 1; i <= n; i++) {
        int crt = mat[i][r] - 'a' + 1;
        lit[i][crt]++;
        if (lit[i][crt] % 2 == 1)
          OK[i]++;
        else
          OK[i]--;
        h[i].first = (h[i].first + p[crt].first) % 998244853;
        h[i].second = (h[i].second + p[crt].second) % 998244853;
      }
      vector<pair<long long, long long> > v;
      for (int i = 1; i <= n; i++) {
        if (OK[i] > 1) {
          if (!v.empty()) solve(v);
          v.clear();
        } else {
          v.push_back(h[i]);
        }
      }
      if (!v.empty()) {
        solve(v);
        v.clear();
      }
    }
  }
  cout << ans << '\n';
  return 0;
}
