#include <bits/stdc++.h>
#define ll long long
#define pii pair<int, int>
using namespace std;

int di[] = {-1, 0, 1, 0};
int dj[] = {0, -1, 0, 1};
int m, n;

bool check(int ci, int cj) { return ci >= 0 && cj >= 0 && ci < m && cj < n; }

int main() {
    cin >> m >> n;
    string s[m];
    for (int i = 0; i < m; i++) cin >> s[i];
    int ans = 0;
    while (true) {
        int ret = 0;
        for (int i = 0; i < m; i++) {
            for (int j = 0; j < n; j++) {
                if (s[i][j] == '.') {
                    pii alp[50];
                    for (int k = 0; k < 50; k++) alp[k] = pii(-1, -1);
                    for (int k = 0; k < 4; k++) {
                        int ci = i, cj = j;
                        while (check(ci, cj) && s[ci][cj] == '.') {
                            ci += di[k];
                            cj += dj[k];
                        }
                        if (check(ci, cj)) {
                            int c = s[ci][cj] - 'A';
                            if (alp[c].first != -1) {
                                pii cur = alp[c];
                                s[ci][cj] = '.';
                                s[cur.first][cur.second] = '.';
                                ret += 2;
                            } else {
                                alp[c] = pii(ci, cj);
                            }
                        }
                    }
                }
            }
        }
        if (ret == 0) break;
        ans += ret;
    }
    cout << ans << endl;
    return 0;
}
