#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define mp make_pair
#define pb push_back
#define lf long double
typedef vector <ll> vi;
typedef pair <ll,ll> ii;
typedef vector <pair <int,int> >vii;
typedef vector <vector <ll> > vv;
typedef vector <string> vs;
ll mod=1000000007;
int main()
{
ll n,m;
cin>>n>>m;
vs s(n,"");
for(ll i=0;i<n;i++)
cin>>s[i];
// vector <vector <ii> > a(n/3+1,vector <ii> ());
map <pair <pair <ll,ll> ,ll > ,bool> ma;
for(ll len=1;len<=n/3;len++)
{
for(ll i=0;i+3*len-1<n;i++)
{
for(ll j=0;j<m;j++)
{
char c1=s[i][j];
bool pos=true;
for(ll i1=i;i1<i+len;i1++)
{
if(s[i1][j]!=c1)
{
pos=false;
break;
}
}
if(pos==false)
continue;
char c2=s[i+len][j];
if(c2==c1)
pos=false;
for(ll i1=i+len;i1<i+2*len;i1++)
{
if(s[i1][j]!=c2)
{
pos=false;
break;
}
}
if(pos==false)
continue;
char c3=s[i+2*len][j];
if(c3==c2)
pos=false;
for(ll i1=i+2*len;i1<i+3*len;i1++)
{
if(s[i1][j]!=c3)
{
pos=false;
break;
}
}
if(pos==false)
continue;
if(pos==true)
{
ma[mp(mp(i,j),len)]=true;
}
}
}
}
ll ans=ma.size();
for(ll len=1;len<=n/3;len++)
{
for(ll i=0;i<n;i++)
{
for(ll j=0;j<m;j++)
{
if(ma[mp(mp(i,j),len)])
{
ll num=1;
char c1=s[i][j];
char c2=s[i+len][j];
char c3=s[i+2*len][j];
ll j1=j+1;
while(j1<m)
{
if(ma[mp(mp(i,j1),len)])
{
if(c1==s[i][j1] && c2==s[i+len][j1] && s[i+2*(len)][j1]==c3)
{
num++;
j1++;
}
else
break;
}
else
{
break;
}
}
ans+=num*(num-1)/2;
j=j1-1;
}
}
}
}
cout<<ans<<endl;
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+CnVzaW5nIG5hbWVzcGFjZSBzdGQ7CiNkZWZpbmUgbGwgbG9uZyBsb25nCiNkZWZpbmUgbXAgbWFrZV9wYWlyCiNkZWZpbmUgcGIgcHVzaF9iYWNrCiNkZWZpbmUgbGYgbG9uZyBkb3VibGUKdHlwZWRlZiB2ZWN0b3IgPGxsPiB2aTsKdHlwZWRlZiBwYWlyIDxsbCxsbD4gaWk7CnR5cGVkZWYgdmVjdG9yIDxwYWlyIDxpbnQsaW50PiA+dmlpOwp0eXBlZGVmIHZlY3RvciA8dmVjdG9yIDxsbD4gPiB2djsKdHlwZWRlZiB2ZWN0b3IgPHN0cmluZz4gdnM7CmxsIG1vZD0xMDAwMDAwMDA3OwppbnQgbWFpbigpCnsKICAgIGxsIG4sbTsKICAgIGNpbj4+bj4+bTsKICAgIHZzIHMobiwiIik7CiAgICBmb3IobGwgaT0wO2k8bjtpKyspCiAgICAgICAgY2luPj5zW2ldOwovLyAgICB2ZWN0b3IgPHZlY3RvciA8aWk+ID4gYShuLzMrMSx2ZWN0b3IgPGlpPiAoKSk7CiAgICBtYXAgPHBhaXIgPHBhaXIgPGxsLGxsPiAsbGwgPiAsYm9vbD4gbWE7CiAgICBmb3IobGwgbGVuPTE7bGVuPD1uLzM7bGVuKyspCiAgICB7CiAgICAgICAgZm9yKGxsIGk9MDtpKzMqbGVuLTE8bjtpKyspCiAgICAgICAgewogICAgICAgICAgICBmb3IobGwgaj0wO2o8bTtqKyspCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgIGNoYXIgYzE9c1tpXVtqXTsKICAgICAgICAgICAgICAgIGJvb2wgcG9zPXRydWU7CiAgICAgICAgICAgICAgICBmb3IobGwgaTE9aTtpMTxpK2xlbjtpMSsrKQogICAgICAgICAgICAgICAgewogICAgICAgICAgICAgICAgICAgIGlmKHNbaTFdW2pdIT1jMSkKICAgICAgICAgICAgICAgICAgICB7CiAgICAgICAgICAgICAgICAgICAgICAgIHBvcz1mYWxzZTsKICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgaWYocG9zPT1mYWxzZSkKICAgICAgICAgICAgICAgICAgICBjb250aW51ZTsKICAgICAgICAgICAgICAgIGNoYXIgYzI9c1tpK2xlbl1bal07CiAgICAgICAgICAgICAgICBpZihjMj09YzEpCiAgICAgICAgICAgICAgICAgICAgcG9zPWZhbHNlOwogICAgICAgICAgICAgICAgZm9yKGxsIGkxPWkrbGVuO2kxPGkrMipsZW47aTErKykKICAgICAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgICAgICBpZihzW2kxXVtqXSE9YzIpCiAgICAgICAgICAgICAgICAgICAgewogICAgICAgICAgICAgICAgICAgICAgICBwb3M9ZmFsc2U7CiAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGlmKHBvcz09ZmFsc2UpCiAgICAgICAgICAgICAgICAgICAgY29udGludWU7CiAgICAgICAgICAgICAgICBjaGFyIGMzPXNbaSsyKmxlbl1bal07CiAgICAgICAgICAgICAgICBpZihjMz09YzIpCiAgICAgICAgICAgICAgICAgICAgcG9zPWZhbHNlOwogICAgICAgICAgICAgICAgZm9yKGxsIGkxPWkrMipsZW47aTE8aSszKmxlbjtpMSsrKQogICAgICAgICAgICAgICAgewogICAgICAgICAgICAgICAgICAgIGlmKHNbaTFdW2pdIT1jMykKICAgICAgICAgICAgICAgICAgICB7CiAgICAgICAgICAgICAgICAgICAgICAgIHBvcz1mYWxzZTsKICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgaWYocG9zPT1mYWxzZSkKICAgICAgICAgICAgICAgICAgICBjb250aW51ZTsKICAgICAgICAgICAgICAgIGlmKHBvcz09dHJ1ZSkKICAgICAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgICAgICBtYVttcChtcChpLGopLGxlbildPXRydWU7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0KICAgICAgICB9CiAgICB9CiAgICBsbCBhbnM9bWEuc2l6ZSgpOwogICAgZm9yKGxsIGxlbj0xO2xlbjw9bi8zO2xlbisrKQogICAgewogICAgZm9yKGxsIGk9MDtpPG47aSsrKQogICAgewogICAgICAgIGZvcihsbCBqPTA7ajxtO2orKykKICAgICAgICB7CiAgICAgICAgICAgIGlmKG1hW21wKG1wKGksaiksbGVuKV0pCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgIGxsIG51bT0xOwogICAgICAgICAgICAgICAgY2hhciBjMT1zW2ldW2pdOwogICAgICAgICAgICAgICAgY2hhciBjMj1zW2krbGVuXVtqXTsKICAgICAgICAgICAgICAgIGNoYXIgYzM9c1tpKzIqbGVuXVtqXTsKICAgICAgICAgICAgICAgIGxsIGoxPWorMTsKICAgICAgICAgICAgICAgIHdoaWxlKGoxPG0pCiAgICAgICAgICAgICAgICB7CiAgICAgICAgICAgICAgICAgICAgaWYobWFbbXAobXAoaSxqMSksbGVuKV0pCiAgICAgICAgICAgICAgICAgICAgewogICAgICAgICAgICAgICAgICAgICAgICBpZihjMT09c1tpXVtqMV0gJiYgYzI9PXNbaStsZW5dW2oxXSAmJiBzW2krMioobGVuKV1bajFdPT1jMykKICAgICAgICAgICAgICAgICAgICAgICAgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgbnVtKys7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBqMSsrOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGVsc2UKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBlbHNlCiAgICAgICAgICAgICAgICAgICAgewogICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBhbnMrPW51bSoobnVtLTEpLzI7CiAgICAgICAgICAgICAgICBqPWoxLTE7CiAgICAgICAgICAgIH0KCiAgICAgICAgfQogICAgfQogICAgfQogICAgY291dDw8YW5zPDxlbmRsOwp9