#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long State[4];
const int MAXN = 251;
const unsigned long long MAX_STATE = 255;
string vals[MAXN];
struct Info {
  int now, nowCnt;
  State s;
  Info() : now(0), nowCnt(0) {
    for (int i = 0; i < 4; i++) {
      s[i] = 0;
    }
  }
  void add(char c) {
    int pos = c - 'a';
    unsigned long long &curVal = s[pos / 8];
    int step = (c - 'a') % 8 * 8;
    curVal += 1ULL << step;
    if ((now >> pos) & 1) {
      nowCnt--;
    } else {
      nowCnt++;
    }
    now ^= (1 << pos);
  }
  bool check() { return nowCnt <= 1; }
  bool operator==(const Info &oI) const {
    for (int i = 0; i < 4; i++) {
      if (s[i] != oI.s[i]) return false;
    }
    return true;
  }
  void clear() {
    now = 0;
    nowCnt = 0;
    for (int i = 0; i < 4; i++) {
      s[i] = 0;
    }
  }
};
struct InfoProxy {
  bool isSpec;
  Info info;
  InfoProxy() : isSpec(true) {}
  InfoProxy(Info info) : isSpec(false), info(info) {}
  void add(char c) {
    if (isSpec) return;
    info.add(c);
  }
  bool check() {
    if (isSpec) return false;
    return info.check();
  }
  void clear() {
    if (isSpec) return;
    info.clear();
  }
  bool operator==(const InfoProxy &oI) const {
    if (isSpec) {
      if (oI.isSpec) return true;
      return false;
    } else {
      if (oI.isSpec) return false;
      return info == oI.info;
    }
  }
} infos[MAXN], tmpInfo[MAXN * 2 + 10];
int RL[MAXN * 2 + 10];
long long manacher(int l, int r) {
  int range = 0;
  long long result = 0;
  tmpInfo[range++] = InfoProxy();
  for (int i = l; i <= r; i++) {
    tmpInfo[range++] = infos[i];
    tmpInfo[range++] = InfoProxy();
  }
  int pos = -1, maxRight = -1;
  for (int i = 0; i < range; i++) {
    if (i < maxRight) {
      RL[i] = min(maxRight - i, RL[2 * pos - i]);
    } else {
      RL[i] = 1;
    }
    while (i + RL[i] < range && i - RL[i] >= 0 &&
           tmpInfo[i + RL[i]] == tmpInfo[i - RL[i]]) {
      RL[i]++;
    }
    if (i + RL[i] - 1 > maxRight) {
      maxRight = i + RL[i] - 1;
      pos = i;
    }
    result += RL[i] / 2;
  }
  return result;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    cin >> vals[i];
  }
  long long result = 0;
  for (int i = 0; i < n; i++) {
    infos[i] = InfoProxy(Info());
  }
  for (int i = 0; i < m; i++) {
    for (int j = 0; j < n; j++) {
      infos[j].clear();
    }
    for (int j = i; j < m; j++) {
      int pre = 0;
      for (int k = 0; k < n; k++) {
        infos[k].add(vals[k][j]);
        if (!infos[k].check()) {
          int suf = k - 1;
          if (pre <= suf) {
            result += manacher(pre, suf);
          }
          pre = k + 1;
        }
      }
      if (pre < n) {
        result += manacher(pre, n - 1);
      }
    }
  }
  cout << result << endl;
  return 0;
}
