#include <bits/stdc++.h>
using namespace std;
const long long INF = 1e9 + 7;
int main() {
  ios::sync_with_stdio(0);
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n, m;
  cin >> n >> m;
  vector<vector<int> > mas(n, vector<int>(m));
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      char b;
      cin >> b;
      mas[i][j] = b - 'a' + 1;
    }
  }
  vector<vector<tuple<int, int, int, int> > > color(
      n + 1,
      vector<tuple<int, int, int, int> >(m + 1, make_tuple(-1, -1, -1, -1)));
  for (int i = 1; i < n - 1; i++) {
    for (int j = 0; j < m; j++) {
      int l = 1;
      if (mas[i - 1][j] == mas[i][j]) {
        continue;
      }
      int c = mas[i][j];
      while (i + l < n && mas[i + l][j] == c) {
        l++;
      }
      if (i < l) {
        continue;
      }
      if (i + 2 * l > n) {
        continue;
      }
      bool f = true;
      int c1 = mas[i - 1][j];
      int c2 = mas[i + l][j];
      for (int k = 1; k <= l; k++) {
        f &= mas[i - k][j] != c;
        f &= mas[i - k][j] == c1;
      }
      if (!f) {
        continue;
      }
      for (int k = 1; k <= l; k++) {
        f &= mas[i + l + k - 1][j] != c;
        f &= mas[i + l + k - 1][j] == c2;
      }
      if (!f) {
        continue;
      }
      color[i][j] = make_tuple(l, mas[i - 1][j], c, mas[i + l][j]);
    }
  }
  tuple<int, int, int, int> dust = make_tuple(-1, -1, -1, -1);
  long long ans = 0;
  for (int i = 1; i < n - 1; i++) {
    int len = 1;
    for (int j = 0; j < m; j++) {
      if (color[i][j] == dust) {
        len = 1;
        continue;
      }
      ans += len;
      if (j < m - 1 && color[i][j] == color[i][j + 1]) {
        len++;
      } else {
        len = 1;
      }
    }
  }
  cout << ans;
  return 0;
}
