#include <bits/stdc++.h>
using namespace std;
using VS = vector<string>;
using LL = long long;
using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;
using PLL = pair<LL, LL>;
using VL = vector<LL>;
using VVL = vector<VL>;
const int INF = 1e9;
const LL LINF = 1e16;
const LL MOD = 1000000007;
const double PI = acos(-1.0);
int DX[8] = {0, 0, 1, -1, 1, 1, -1, -1};
int DY[8] = {1, -1, 0, 0, 1, -1, 1, -1};
int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  int H, W;
  cin >> H >> W;
  VS vs(H);
  for (int(i) = (0); (i) < (H); (i)++) {
    cin >> vs[i];
    for (int(j) = (0); (j) < (W); (j)++) {
      vs[i][j] -= 'a';
    }
  }
  LL ans = 0;
  for (int(L) = (0); (L) < (W); (L)++) {
    int sz = 2 * H + 1;
    VVI asum(sz, VI(27, 0));
    VI state(sz, 0);
    for (int(R) = (L); (R) < (W); (R)++) {
      for (int(i) = (0); (i) < (H); (i)++) {
        asum[2 * i + 1][vs[i][R]]++;
        state[2 * i + 1] ^= 1 << vs[i][R];
      }
      int no = 1;
      for (int(i) = (0); (i) < (H); (i)++) {
        if (__builtin_popcount(state[2 * i + 1]) > 1)
          asum[2 * i + 1][26] = no++;
        else
          asum[2 * i + 1][26] = 0;
      }
      VI radius(sz, 0);
      int i = 0, j = 0;
      while (i < (int)asum.size()) {
        while (i - j >= 0 && i + j < (int)asum.size() &&
               asum[i - j] == asum[i + j]) {
          ++j;
        }
        radius[i] = j;
        int k = 1;
        while (i - k >= 0 && i + k < (int)asum.size() &&
               k + radius[i - k] < j) {
          radius[i + k] = radius[i - k];
          ++k;
        }
        i += k;
        j -= k;
      }
      auto getOddR = [&radius](int k) {
        ;
        return radius[2 * k + 1] / 2;
      };
      auto getEvenR = [&radius](int k) {
        ;
        return (radius[2 * k + 2] - 1) / 2;
      };
      for (int(i) = (0); (i) < (H); (i)++) {
        ans += getEvenR(i);
      }
      for (int(i) = (0); (i) < (H); (i)++) {
        if (asum[2 * i + 1][26] == 0) {
          ans += getOddR(i);
        }
      }
    }
  }
  cout << ans << endl;
  return 0;
}
