#include<iostream>
#include<sstream>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<complex>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cassert>

#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define mp make_pair
#define pb push_back
#define each(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define dbg(x) cerr<<__LINE__<<": "<<#x<<" = "<<(x)<<endl

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
const int inf = (int)1e9;
const double INF = 1e12, EPS = 1e-9;

const int dy[] = {-1, 0, 1, 0}, dx[] = {0, -1, 0, 1};
int h, w;
int n[512][512][4];
char in[512][512];
inline int next(int y, int x, int d){
	if(y < 0 || y >= h || x < 0 || x >= w || n[y][x][d] == -2) return -2;
	if(in[y][x] != '.') return n[y][x][d] = y * w + x;
	if(n[y][x][d] >= 0 && in[n[y][x][d] / w][n[y][x][d] % w] != '.') return n[y][x][d];
	return n[y][x][d] = next(y + dy[d], x + dx[d], d);
}

int main(){
	cin >> h >> w;
	rep(i, h) cin >> in[i];
	memset(n, -1, sizeof(n));
	
	int ans = 0;
	while(1){
		bool update = 0;
		rep(i, h) rep(j, w) if(in[i][j] == '.'){
			rep(d, 4) rep(e, d){
				int a = next(i, j, d), b = next(i, j, e);
				if(a < 0 || b < 0) continue;
				int ay = a / w, ax = a % w;
				int by = b / w, bx = b % w;
				if(in[ay][ax] != in[by][bx]) continue;
				in[ay][ax] = in[by][bx] = '.';
				ans += 2;
				update = 1;
			}
		}
		if(!update) break;
	}
	cout << ans << endl;
	return 0;
}