#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
const int C = 26;
void add(int &x, int y) {
  x += y;
  while (x >= MOD) x -= MOD;
  while (x < 0) x += MOD;
}
int fix(int x) {
  while (x >= MOD) x -= MOD;
  while (x < 0) x += MOD;
  return x;
}
int pw(int a, int b) {
  int ret = 1;
  while (b) {
    if (b & 1) ret = 1ll * ret * a % MOD;
    b >>= 1;
    a = 1ll * a * a % MOD;
  }
  return ret;
}
const int MAXN = 250 + 10;
int manachers(vector<unsigned long long> s) {
  int n = s.size();
  vector<int> d1(n);
  int ans = 0;
  for (int i = 0, l = 0, r = -1; i < n; i++) {
    int k = (i > r) ? 1 : min(d1[l + r - i], r - i + 1);
    while (0 <= i - k && i + k < n && s[i - k] == s[i + k]) {
      k++;
    }
    d1[i] = k--;
    ans += d1[i];
    if (i + k > r) {
      l = i - k;
      r = i + k;
    }
  }
  vector<int> d2(n);
  for (int i = 0, l = 0, r = -1; i < n; i++) {
    int k = (i > r) ? 0 : min(d2[l + r - i + 1], r - i + 1);
    while (0 <= i - k - 1 && i + k < n && s[i - k - 1] == s[i + k]) {
      k++;
    }
    d2[i] = k--;
    ans += d2[i];
    if (i + k > r) {
      l = i - k - 1;
      r = i + k;
    }
  }
  return ans;
}
int n, m;
char grid[MAXN][MAXN];
unsigned long long hsh[MAXN];
unsigned long long pre[MAXN][MAXN];
bool pal[MAXN][MAXN][MAXN];
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
void solve() {
  scanf("%d%d", &n, &m);
  for (int i = 0; i < n; i++) scanf("%s", grid[i]);
  for (int i = 0; i < MAXN; i++) hsh[i] = rng();
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      int mask = 0;
      for (int k = j; k < m; k++) {
        mask ^= 1 << (grid[i][k] - 'a');
        if (__builtin_popcount(mask) <= 1) {
          pal[i][j][k] = 1;
        }
      }
    }
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      pre[i][j + 1] = pre[i][j] + hsh[(int)grid[i][j]];
    }
  }
  int ans = 0;
  for (int j = 0; j < m; j++) {
    for (int k = j; k < m; k++) {
      vector<unsigned long long> vec;
      for (int i = 0; i < n; i++) {
        if (!pal[i][j][k]) {
          ans += manachers(vec);
          vec.clear();
        } else {
          vec.push_back(pre[i][k + 1] - pre[i][j]);
        }
      }
      ans += manachers(vec);
    }
  }
  printf("%d\n", ans);
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int te = 1;
  for (int w = 1; w <= te; w++) {
    solve();
  }
  return 0;
}
