#include <bits/stdc++.h>
using namespace std;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
template <class T>
void IN(T& x) {
  cin >> x;
}
template <class H, class... T>
void IN(H& h, T&... t) {
  IN(h);
  IN(t...);
}
template <class T1, class T2>
void OUT(const pair<T1, T2>& x);
template <class T>
void OUT(const vector<T>& x);
template <class T>
void OUT(const T& x) {
  cout << x;
}
template <class H, class... T>
void OUT(const H& h, const T&... t) {
  OUT(h);
  OUT(t...);
}
template <class T1, class T2>
void OUT(const pair<T1, T2>& x) {
  OUT(x.first, ' ', x.second);
}
template <class T>
void OUT(const vector<T>& x) {
  for (int i = int(0); i < int(x.size()); i++) OUT(i == 0 ? "" : " ", x[i]);
}
template <class... T>
void OUTL(const T&... t) {
  OUT(t..., "\n");
}
template <class H>
void OUTLS(const H& h) {
  OUTL(h);
}
template <class H, class... T>
void OUTLS(const H& h, const T&... t) {
  OUT(h, ' ');
  OUTLS(t...);
}
void program();
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  program();
}
const int MX = 300, MX2 = 1e6;
int n, m;
string gr[MX];
int dif[MX];
long long sum[MX];
long long hsh[MX];
map<int, char> mp;
struct Node {
  vector<pair<int, int> > nxt;
  int sufflink, len;
  int cnt = 0;
} tree[MX2];
vector<int> s;
int suf, num;
void initTree() {
  num = suf = 2;
  tree[1].len = -1;
  tree[1].sufflink = 1;
  tree[2].len = 0;
  tree[2].sufflink = 1;
  for (int i = int(1); i < int(2 + 1); i++) tree[i].nxt.clear();
}
int addLetter(int pos) {
  int cur = suf, curLen = 0;
  int letter = s[pos];
  while (1) {
    curLen = tree[cur].len;
    if (pos - 1 - curLen >= 0 && s[pos - 1 - curLen] == s[pos]) break;
    cur = tree[cur].sufflink;
  }
  for (auto& p : tree[cur].nxt)
    if (p.first == letter) {
      suf = p.second;
      return tree[suf].cnt;
    }
  suf = ++num;
  tree[num].nxt.clear();
  tree[num].cnt = 1;
  tree[num].len = tree[cur].len + 2;
  tree[cur].nxt.push_back({letter, suf});
  if (tree[num].len == 1) {
    tree[num].sufflink = 2;
    return tree[suf].cnt;
    ;
  }
  while (1) {
    cur = tree[cur].sufflink;
    curLen = tree[cur].len;
    if (pos - 1 - curLen >= 0 && s[pos - 1 - curLen] == s[pos]) {
      for (auto& p : tree[cur].nxt)
        if (p.first == letter) {
          tree[num].sufflink = p.second;
          tree[num].cnt += tree[tree[num].sufflink].cnt;
          return tree[suf].cnt;
          ;
        }
    }
  }
}
int countPalin() {
  initTree();
  int res = 0;
  for (int i = int(0); i < int(s.size()); i++) res += addLetter(i);
  return res;
}
void program() {
  IN(n, m);
  for (int i = int(0); i < int(n); i++) IN(gr[i]);
  for (int i = int(0); i < int(n); i++)
    for (int j = int(0); j < int(m); j++) gr[i][j] -= 'a';
  for (int i = int(0); i < int(26); i++) mp[1 << i] = 1;
  for (int i = int(0); i < int(26); i++) hsh[i] = rng();
  mp[0] = 1;
  long long ans = 0;
  for (int j1 = int(0); j1 < int(m); j1++) {
    for (int i = int(0); i < int(n); i++) dif[i] = sum[i] = 0;
    for (int j2 = int(j1); j2 < int(m); j2++) {
      for (int i = int(0); i < int(n); i++) {
        dif[i] ^= (1 << gr[i][j2]);
        sum[i] += hsh[gr[i][j2]];
        auto it = mp.find(dif[i]);
        if (it == mp.end()) {
          ans += countPalin();
          s.clear();
        } else {
          s.push_back(sum[i]);
        }
      }
      ans += countPalin();
      s.clear();
    }
  }
  OUTL(ans);
}
