#include <bits/stdc++.h>
using namespace std;
const int N = 259, K = 'z' - 'a' + 1, base = 301, inf = 1e9 + 9;
int n, m, cnt[N][N][K], kq = 0, x[3 * N];
void Inp() {
  cin >> m >> n;
  char ch;
  for (int i = 1; i <= m; i++) {
    for (int j = 1; j <= n; j++) {
      cin >> ch;
      for (int k = 0; k < K; k++) {
        cnt[i][j][k] = cnt[i][j - 1][k];
      }
      cnt[i][j][ch - 'a']++;
    }
  }
}
void Calc(int L, int R) {
  vector<int> p;
  p.push_back(-1);
  for (int i = 1; i <= m; ++i) {
    int sum = 0, Cnt = 0;
    for (int k = 0; k < K; ++k) {
      sum = (sum * base + (cnt[i][R][k] - cnt[i][L - 1][k]));
      if ((cnt[i][R][k] - cnt[i][L - 1][k]) % 2 == 1) {
        Cnt++;
      }
    }
    if (Cnt > 1) {
      p.push_back(inf);
    } else {
      p.push_back(sum);
    }
    p.push_back(-1);
  }
  int sz = p.size();
  int l = 0, r = 0;
  for (int i = 0; i < sz; i++) {
    if (p[i] == inf) {
      continue;
    }
    if (i >= r) {
      x[i] = 0;
    } else {
      x[i] = min(x[l + r - i], r - i);
    }
    x[i]++;
    while (i - x[i] >= 0 && i + x[i] < sz && p[i - x[i]] == p[i + x[i]] &&
           p[i - x[i]] != inf && p[i + x[i]] != inf) {
      x[i]++;
    }
    x[i]--;
    if (r < i + x[i]) {
      l = i - x[i];
      r = i + x[i];
    }
    kq = kq + (x[i] + 1) / 2;
  }
}
void Solve() {
  for (int i = 1; i <= n; ++i) {
    for (int j = i; j <= n; ++j) {
      Calc(i, j);
    }
  }
  cout << kq;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  Inp();
  Solve();
}
