#include <bits/stdc++.h>
using namespace std;
inline char in() {
  char x;
  cin >> x;
  return x;
}
const int N = 255;
const int base = 251;
const int key = 1000000007;
int m, n;
long long ans;
int odd[N], u[N], d[N];
int cnt[N][30], a[N][N];
unsigned long long pw[N], lk[N], f[N], g[N][2];
unsigned long long H(int i, int j, int o) {
  if (o == 0) return g[j][o] - g[i - 1][o] * lk[j - i + 1];
  return g[j][o] - g[i + 1][o] * lk[i - j + 1];
}
void rev(int i, int c) {
  f[i] += pw[c];
  odd[i] -= (cnt[i][c] & 1);
  cnt[i][c]++;
  odd[i] += (cnt[i][c] & 1);
}
void solve(int _) {
  for (int i = 1, _c = m; i <= _c; ++i)
    for (int j = 0, _c = 25; j <= _c; ++j) cnt[i][j] = 0;
  for (int i = 1, _c = m; i <= _c; ++i) f[i] = odd[i] = 0;
  for (int i = _, _c = n; i <= _c; ++i) {
    for (int t = 1, _c = m; t <= _c; ++t) rev(t, a[t][i]);
    for (int t = 1, _c = m; t <= _c; ++t) g[t][0] = g[t - 1][0] * key + f[t];
    for (int t = m, _c = 1; t >= _c; --t) g[t][1] = g[t + 1][1] * key + f[t];
    for (int t = 1, _c = m; t <= _c; ++t)
      u[t] = odd[t - 1] <= 1 && t > 1 ? u[t - 1] : t;
    for (int t = m, _c = 1; t >= _c; --t)
      d[t] = odd[t + 1] <= 1 && t < m ? d[t + 1] : t;
    for (int t = 1, _c = m; t <= _c; ++t)
      if (odd[t] <= 1) {
        int l = 0, mid, r = min(t - u[t], d[t] - t), re = 0;
        while (l <= r) {
          mid = l + (r - l) / 2;
          if (H(t, t + mid, 0) == H(t, t - mid, 1))
            re = mid + 1, l = mid + 1;
          else
            r = mid - 1;
        }
        ans += re;
        if (odd[t + 1] > 1 || t == m) continue;
        l = 0, r = min(t - u[t], d[t + 1] - t - 1), re = 0;
        while (l <= r) {
          mid = l + (r - l) / 2;
          if (H(t + 1, t + 1 + mid, 0) == H(t, t - mid, 1))
            re = mid + 1, l = mid + 1;
          else
            r = mid - 1;
        }
        ans += re;
      }
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cin >> m >> n;
  for (int i = 1, _c = m; i <= _c; ++i)
    for (int j = 1, _c = n; j <= _c; ++j) a[i][j] = in() - 'a';
  pw[0] = lk[0] = 1;
  for (int i = 1, _c = 250; i <= _c; ++i)
    pw[i] = pw[i - 1] * base, lk[i] = lk[i - 1] * key;
  for (int i = 1, _c = n; i <= _c; ++i) solve(i);
  cout << ans;
}
