#include<iostream>
#include<vector>
#include<algorithm>
#define PII pair<int, int>
#define REP(i, n) for(int i=0;i<(n);++i)
#define atoi(x) (x - 'A')
using namespace std;
int H, W;
vector<vector<char> > map;
vector<vector<PII > > alp;
void outmap(){
    REP(y, H){
        REP(x, W){
            cout << map[y][x];
        }
        cout << endl;
    }
}
bool check(int sy, int sx, int gy, int gx) {
    if(abs(sy-gy)+abs(sx-gx)==1)return false;
	int count = 0;
	for (int x = min(sx, gx); x <= max(sx, gx); ++x) {
		count += map[sy][x] != '.';
	}
	for (int y = min(sy, gy); y <= max(sy, gy); ++y) {
		count += map[y][gx] != '.';
	}
    count -= map[sy][gx] != '.';
	if (count == 2)return true;
	count = 0;
	for (int y = min(sy, gy); y <= max(sy, gy); ++y) {
		count += map[y][sx] != '.';
	}
	for (int x = min(sx, gx); x <= max(sx, gx); ++x) {
		count += map[gy][x] != '.';
	}
    count -= map[gy][sx] != '.';
	if (count == 2)return true;
	return false;
}
int main() {
	cin >> H >> W;
	map.resize(H);
	alp.resize(26);
	REP(i, H) {
		map[i].resize(W);
		REP(j, W) {
			cin >> map[i][j];
			if (map[i][j] != '.') {
				alp[atoi(map[i][j])].push_back(PII(i, j));
			}
		}
	}
	bool flag = true;
	int ans = 0;
	while (flag) {
		flag = false;
		REP(i, 26) {
			if (alp[i].empty())continue;
			if (!check(alp[i][0].first, alp[i][0].second, alp[i][1].first, alp[i][1].second))continue;
            ans += 2;
			map[alp[i][0].first][alp[i][0].second] = '.';
			map[alp[i][1].first][alp[i][1].second] = '.';
            alp[i].clear();
            flag = true;
		}
	}
	cout << ans << endl;
	return 0;
}

