#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
const int B = 204323111;
const int Bx = 99;
const int MAXN = 255;
int n, m;
string S[MAXN];
int xr[MAXN][MAXN];
ull hs[MAXN][MAXN], powb[MAXN], powbx[MAXN];
vector<ull> g[MAXN];
ll sol = 0;
ull hh[MAXN], hh_rev[MAXN];
ll solve(vector<ull>& v) {
  ll ret = 0;
  ull h = 0;
  hh[v.size()] = 0;
  for (int i = v.size() - 1; i >= 0; --i) {
    h = h * B + v[i];
    hh[i] = h;
  }
  h = 0;
  for (int i = 0; i < v.size(); ++i) {
    h = h * B + v[i];
    hh_rev[i] = h;
  }
  for (int i = 0; i < v.size(); ++i) {
    int l = 0, r = min(i, (int)v.size() - 1 - i);
    int best = 0;
    while (l <= r) {
      int mid = (l + r) / 2;
      int lb = i - mid, rb = i + mid;
      if (hh[lb] - hh[rb + 1] * powb[rb - lb + 1] ==
          hh_rev[rb] - ((lb == 0) ? 0 : (hh_rev[lb - 1] * powb[rb - lb + 1]))) {
        best = mid;
        l = mid + 1;
      } else
        r = mid - 1;
    }
    ret += best + 1;
  }
  for (int i = 0; i < v.size() - 1; ++i) {
    if (v[i] == v[i + 1]) {
      int l = 0, r = min(i, (int)v.size() - 1 - (i + 1));
      int best = 0;
      while (l <= r) {
        int mid = (l + r) / 2;
        int lb = i - mid, rb = i + 1 + mid;
        if (hh[lb] - hh[rb + 1] * powb[rb - lb + 1] ==
            hh_rev[rb] -
                ((lb == 0) ? 0 : (hh_rev[lb - 1] * powb[rb - lb + 1]))) {
          best = mid;
          l = mid + 1;
        } else
          r = mid - 1;
      }
      ret += best + 1;
    }
  }
  return ret;
}
int main() {
  powb[0] = 1;
  powbx[0] = 1;
  for (int i = 1; i < MAXN; ++i) {
    powb[i] = powb[i - 1] * B;
    powbx[i] = powbx[i - 1] * Bx;
  }
  cin >> n >> m;
  for (int i = 0; i < n; ++i) {
    cin >> S[i];
    int x = 0;
    ull h = 0;
    for (int j = m - 1; j >= 0; --j) {
      x = x ^ (1 << (S[i][j] - 'a'));
      xr[i][j] = x;
      h += powbx[S[i][j] - 'a'];
      hs[i][j] = h;
    }
  }
  int gsz = 0;
  for (int j1 = 0; j1 < m; ++j1)
    for (int j2 = j1; j2 < m; ++j2) {
      bool odd = (j2 - j1 + 1) % 2;
      for (int k = 0; k < gsz; ++k) g[k].clear();
      gsz = 0;
      for (int i = 0; i < n; ++i) {
        int xrj = xr[i][j1] ^ xr[i][j2 + 1];
        int set_bits = __builtin_popcount(xrj);
        bool next = 0;
        if (odd && set_bits != 1) next = 1;
        if (!odd && set_bits != 0) next = 1;
        if (next && g[gsz].size() != 0) gsz++;
        if (!next) g[gsz].push_back(hs[i][j1] - hs[i][j2 + 1]);
      }
      if (g[gsz].size() != 0) gsz++;
      for (int k = 0; k < gsz; ++k) sol += solve(g[k]);
    }
  cout << sol;
  return 0;
}
