#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <functional>
#include <algorithm>

using namespace std;

#define rep(i,j) REP((i), 0, (j))
#define REP(i,j,k) for(int i=(j);(i)<(k);++i)
#define BW(a,x,b) ((a)<=(x)&&(x)<=(b))
#define ALL(v) (v).begin(), (v).end()
#define LENGTHOF(x) (sizeof(x) / sizeof(*(x)))
#define AFILL(a, b) fill((int*)a, (int*)(a + LENGTHOF(a)), b)
#define SQ(x) ((x)*(x))
#define Mod(x, mod) (((x)+(mod)%(mod))
#define MP make_pair
#define PB push_back
#define Fi first
#define Se second
#define INF (1<<29)
#define EPS 1e-10
#define MOD 1000000007

typedef pair<int, int> P;
typedef vector<int> vi;
typedef queue<int> qi;
typedef long long ll;

int M,N;
char C[512][512], c[512][512];
int dy[]={-1,0,1,0},dx[]={0,-1,0,1};

int del(int y, int x){
  vector<P>v;
  rep(d,4){
    int ny=y+dy[d], nx=x+dx[d];
    while(ny>=0&&ny<M&&nx>=0&&nx<N&&c[ny][nx]=='.') ny += dy[d], nx += dx[d];
    if(ny<0||ny>=M||nx<0||nx>=N) continue;
    v.push_back(P(ny, nx));
  }
  int ret = 0;
  rep(i, v.size()) for(int j=i+1;j<v.size();j++){
    if(c[v[i].first][v[i].second] != '.' && c[v[i].first][v[i].second] == c[v[j].first][v[j].second]){
      ret++;
      c[v[i].first][v[i].second] = c[v[j].first][v[j].second] =  '.';
    }
  }
  return ret;
}

int main(){
  scanf("%d%d", &M,&N);
  rep(i,M) scanf("%s", C[i]);
  rep(i,M) rep(j,N) c[i][j] = C[i][j];
  int f = 1;
  while(f){
    f = 0;
    rep(i,M) rep(j,N) if(c[i][j]=='.') f += del(i, j);
  }
  int res = 0;
  rep(i,M) rep(j,N) if(c[i][j]!=C[i][j]) res++;
  //  rep(i,M) puts(c[i]);
  printf("%d\n", res);
  return 0;
}