#include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define vi vector<ll>
#define vvi vector<vi>
#define BITLE(n) (1LL<<((ll)n))
#define SUBS(s,f,t) ((s).substr((f),(t)-(f)))
#define ALL(a) (a).begin(),(a).end()
#define Max(a) (*max_element(ALL(a)))
#define Min(a) (*min_element(ALL(a)))
using namespace std;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s;cin>>s;
  ll n = s.size();
  reverse(ALL(s));
  vi cnt(33);
  ll ans = 0;
  s.pb('!');
  s.pb('#');
  for(int i=0;i<=n-2;i++){
    //   cout<<i<<" "<<i+1<<" "<<i+2<<endl;
    //cout<<s[i]<<" "<<s[i+1]<<" "<<s[i+2]<<endl;
    if(s[i+1] == s[i+2] && s[i] != s[i+2]){
      //cout<<i+1<<" "<<cnt[s[i+1]-'a']<<endl;
      ans += i+1-cnt[s[i+1]-'a'];
      for(int j=0;j<26;j++){
	cnt[j] = 0;
      }
      cnt[s[i+1]-'a'] = i+3;
      i++;
      //cout<<s[i+1]<<" "<<s[i+1]<<" "<<s[i+2]<<endl;
      if(!(s[i+2] == s[i+3] && s[i+1] != s[i+3]))i++;
    }else{
      cnt[s[i]-'a']++;
    }
  }
  cout<<ans<<endl;
  return 0;
}

#include<iostream>
#include<vector>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<queue>
#include<deque>
#include<map>
#include<bitset>
using namespace std;

typedef long long ll;
#define rep(i, n) for(int i = 0;i < (n);i++)
#define repr(i, n) for(int i = (n);i >= 0;i--)
#define repf(i, m, n) for(int i = (m);i < (n);i++)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1;} return 0;}
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1;} return 0;}
int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};
//////////////////////////////////////////////////


int main() {
    int h, w; cin >> h >> w;
    vector<string> s(h);
    rep(i,h) cin >> s[i];

    int ans = 0;
    rep(i,h) rep(j,w-1) {
        if (s[i][j] == '.' && s[i][j+1] == '.') ans++;
    }
    rep(i,h-1) rep(j,w) {
        if (s[i][j] == '.' && s[i+1][j] == '.') ans++;
    }
    cout << ans << endl;
    return 0;
}