#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
void fileio(){
    #ifdef LOCAL
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
}
#define int ll
#define ld long double
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define START_TIMER auto start = std::chrono::high_resolution_clock::now();
#define END_TIMER(msg) \
    auto end = std::chrono::high_resolution_clock::now(); \
    std::cout << msg << ": " \
              << std::chrono::duration_cast<std::chrono::milliseconds>(end - start).count() \
              << " ms" << std::endl;

using namespace std;
const double pi = 3.14159265358979;

int cnt=0;
int H,W;
vector<string> grid;

bool sym(int h1,int h2,int w1,int w2){
    int hh=h1+h2,ww=w1+w2;
    for (int i = h1; i <=h2; i++)
    {
        for (int j = w1; j <=w2; j++)
        {
            //cout<<hh-i<<" "<<ww-j<<endl;
            if(grid[i][j]!=grid[hh-i][ww-j]) return false;
        }
    }
    return true;
}

void comp(int h,int w){
    for (int i = h; i < H; i++)
    {
        for (int j = w; j < W; j++)
        {
            if(sym(h,i,w,j)) cnt++;
        }
    }
    
}

void solve()
{
    cin>>H>>W;
    grid.resize(H);
    for (int i = 0; i < H; i++)
    {
        cin>>grid[i];
    }
    
    for (int i = 0; i < H; i++)
    {
        for (int j = 0; j < W; j++)
        {
            comp(i,j);
        }
    }
    cout<<cnt;

}

signed main()
{
    fileio();
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    ll t=1;//cin>>t;
    while(t--)
    {solve();}
}
