#include <bits/stdc++.h>
#pragma OPTIMIZE("O3")
using namespace std;
inline void file() {
  ios_base::sync_with_stdio(false);
  cout.tie(NULL);
  cin.tie(NULL);
}
const int N = 252;
int my, mx, sum[N][N][26];
char good[N];
unsigned st[32], h[N];
int solve5() {
  int ans = 0;
  for (int lx = 0; lx < mx; ++lx)
    for (int rx = lx + 1; rx <= mx; ++rx) {
      for (int y = 1; y <= my; ++y) {
        int cnt = 0;
        good[y] = true;
        for (int k = 0; k < 26; ++k)
          if ((sum[y][rx][k] - sum[y][lx][k]) & 1)
            if (++cnt == 2) {
              good[y] = false;
              break;
            }
      }
      for (int y = 1; y <= my; ++y)
        if (good[y]) {
          h[y] = 0;
          for (int k = 0; k < 26; ++k)
            h[y] += (sum[y][rx][k] - sum[y][lx][k]) * st[k];
        }
      for (int y = 1; y <= my; ++y)
        if (good[y]) {
          ++ans;
          for (int s = 1; good[y - s] && good[y + s] && h[y - s] == h[y + s];
               ++s)
            ++ans;
          for (int s = 1;
               good[y - s + 1] && good[y + s] && h[y - s + 1] == h[y + s]; ++s)
            ++ans;
        }
    }
  return ans;
}
int main() {
  file();
  st[0] = 1;
  for (int i = 1; i < 32; ++i) st[i] = st[i - 1] * 211;
  scanf("%d %d", &my, &mx);
  char h = 0;
  for (int y = 1; y <= my; ++y)
    for (int x = 1; x <= mx; ++x) {
      for (int k = 0; k < 26; ++k) sum[y][x][k] = sum[y][x - 1][k];
      for (scanf("%c", &h); h < 'a' || h > 'z';) scanf("%c", &h);
      sum[y][x][h - 'a']++;
    }
  printf("%d", solve5());
}
