#include <bits/stdc++.h>
#define ALL(s) (s).begin(),(s).end()
using namespace std;
using ll=long long;
ll M=1000000007LL;
int main(void)
{
    ll h,w,ans=0; cin>>h>>w; vector<string> s(h);
    for(ll i=0;i<h;i++) cin>>s[i];
    for(ll i=0;i<h;i++)
    {
        for(ll j=0;j<w-1;j++)
        {
            if(s[i][j]==s[i][j+1]&&s[i][j]=='.') ans++;
        }
    }
    for(ll i=0;i<w;i++)
    {
        for(ll j=0;j<h-1;j++)
        {
            if(s[j][i]==s[j+1][i]&&s[j][i]=='.') ans++;
        }
    }
    cout<<ans<<endl;
}

#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <random>
#include <chrono>
#include <tuple>
#include <random>
#include <cmath>

using namespace std;

typedef long long ll;
typedef long double ld;
#define fastInp cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);

const ll SIZE = 1e6 * 2 + 10, INF = 1e9 * 1e9 + 10;

ll symb(char a) {
    if (a == 'A') return 0;
    if (a == 'T') return 1;
    if (a == 'C') return 2;
    if (a == 'G') return 3;
}

int main()
{
    fastInp;

    string s;
    ll n;
    cin >> n >> s;

    ll ans = 0;
    for (int i = 0; i < s.size(); i++) {
        vector<ll> k(4);
        for (int j = i; j < s.size(); j++) {
            k[symb(s[j])]++;
            if (k[0] == k[1] && k[2] == k[3]) ans++;
        }
    }

    cout << ans;
    
    return 0;
}