#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <algorithm>
#include <cmath>

using namespace std;

#define rep(i,n) for(int i = 0;i < n;i++)
#define int long long

int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
bool ok(int x, int y, int w, int h) {
	return x >= 0 && y >= 0 && w > x && h > y;
}

signed main() {
	int h, w;
	cin >> h >> w;
	vector<string> s(h);
	map<char, vector<pair<int, int>>> mp;
	rep(y, h) {
		cin >> s[y];
		rep(x, w) {
			if (s[y][x] != '.') {
				mp[s[y][x]].push_back(make_pair(y, x));
			}
		}
	}
	int ans = 0;
	while (1) {
		bool end = true;
		for (char c = 'A'; c <= 'Z'; c++) {
			if (mp[c].size() == 0)continue;
			[&]() {
				rep(i, 4)rep(j, 4) {
					bool rm = false;
					int iy = mp[c][0].first, ix = mp[c][0].second;
					int jy = mp[c][1].first, jx = mp[c][1].second;
					int ay = iy + dy[i], ax = ix + dx[i];
					int by = jy + dy[j], bx = jx + dx[j];

					set<pair<int, int>> av;
					while (ok(ax, ay, w, h)) {
						if (s[ay][ax] == '.') {
							av.insert(make_pair(ay, ax));
							ay += dy[i]; ax += dx[i];
						}
						else break;
					}
					while (ok(bx, by, w, h)) {
						if (s[by][bx] == '.') {
							if (av.count(make_pair(by, bx))) {
								rm = true; break;
							}
							by += dy[j]; bx += dx[j];
						}
						else break;
					}
					if (rm) {
						s[iy][ix] = '.';
						s[jy][jx] = '.';
						mp[c].clear();
						ans += 2;
						end = false;
						return;
					}
				}
			}();
		}
		if (end)break;
	}
	cout << ans << endl;

	return 0;
}