#include "bits/stdc++.h"
using namespace std;
using i64 = long long;
const i64 MOD = 1e9+7;
const i64 INF = 1e18+7;


template <typename T>
bool chmin(T& x, T y){
    if(x > y){
        x = y;
        return true;
    }
    return false;
}

template <typename T>
bool chmax(T& x, T y){
    if(x < y){
        x = y;
        return true;
    }
    return false;
}


bool solve(){
    int h, w;
    cin >> h >> w;
    vector<string> s(h);
    for(auto& x : s)
        cin >> x;
    vector<vector<pair<int,int>>> v(26);
    for(int i = 0; i < h; ++i)
        for(int j = 0; j < w; ++j){
            if(s[i][j] != '.'){
                v[s[i][j] - 'A'].emplace_back(i, j);
            }
        }

    auto check = [&](int i){
        int sx = min(v[i][0].first, v[i][1].first);
        int sy = min(v[i][0].second, v[i][1].second);
        int ex = max(v[i][0].first, v[i][1].first);
        int ey = max(v[i][0].second, v[i][1].second);
        if(abs(sx - ex) + abs(sy - ey) == 1)
            return false;
        if(sx == ex){
            bool fl = true;
            for(int y = sy + 1; y < ey; ++y)
                if(s[sx][y] != '.'){
                    fl = false;
                    break;
                }
            if(fl)
                return true;
        }
        else if(sy == ey){
            bool fl = true;
            for(int x = sx + 1; x < ex; ++x)
                if(s[x][sy] != '.'){
                    fl = false;
                    break;
                }
            if(fl)
                return true;
        }
        else if(min(v[i][0], v[i][1]) == make_pair(sx, sy)){
            bool fl = true;
            for(int x = sx + 1; x <= ex; ++x)
                if(s[x][sy] != '.'){
                    fl = false;
                    break;
                }
            for(int y = sy + 1; y < ey; ++y)
                if(s[ex][y] != '.'){
                    fl = false;
                    break;
                }
            if(fl)
                return true;
            fl = true;
            for(int x = sx; x < ex; ++x)
                if(s[x][ey] != '.'){
                    fl = false;
                    break;
                }
            for(int y = sy + 1; y < ey; ++y)
                if(s[sx][y] != '.'){
                    fl = false;
                    break;
                }
            if(fl)
                return true;
        }
        else{
            bool fl = true;
            for(int x = sx + 1; x < ex; ++x)
                if(s[x][sy] != '.'){
                    fl = false;
                    break;
                }
            for(int y = sy; y < ey; ++y)
                if(s[sx][y] != '.'){
                    fl = false;
                    break;
                }
            if(fl)
                return true;
            fl = true;
            for(int x = sx + 1; x <= ex; ++x)
                if(s[x][ey] != '.'){
                    fl = false;
                    break;
                }
            for(int y = sy + 1; y < ey; ++y)
                if(s[ex][y] != '.'){
                    fl = false;
                    break;
                }
            if(fl)
                return true;
        }
        return false;
    };

    bool fl = true;
    int ans = 0;
    while(fl){
        fl = false;
        for(int i = 0; i < 26; ++i)
            if(!v[i].empty()){
                if(check(i)){
                    fl = true;
                    for(auto& p : v[i])
                        s[p.first][p.second] = '.';
                    v[i].clear();
                    ans += 2;
                    break;
                }
            }

        /*
        for(auto& x : s)
            cout << x << endl;
        cout << endl;
         */
    }
    cout << ans << endl;

    return false;
}


signed main(){
    while(solve());
}



Measured memory_bytes: 3340