#include <bits/stdc++.h>
#define ll long long
#define INF 1000000005
#define MOD 1000000007
#define EPS 1e-10
#define rep(i,n) for(int i=0;i<(int)n;++i)

using namespace std;

typedef pair<int,int>P;

const int MAX_N = 501;

int main()
{
    int n,m;
    scanf("%d%d",&n,&m);
    char c[MAX_N][MAX_N];
    vector<P> al[26];
    int res = 0;
	rep(i,n){
        char hoge;
        scanf("%c",&hoge);
        rep(j,m){
            scanf("%c",&c[i][j]);
            if((int)(c[i][j] - 'A') >= 0 && (int)(c[i][j] - 'A') <= 25){
                al[(int)(c[i][j] - 'A')].push_back(P(i,j));
            }
        }
	}
    while(1){
        bool act = false;
        rep(i,26){
            if(al[i].size() > 0){
                int i1 = al[i][0].first,j1 = al[i][0].second;
                int i2 = al[i][1].first,j2 = al[i][1].second;
                if(i1 == i2){
                    bool flag = false;
                    if(abs(j1-j2) == 1){
                        continue;
                    }
                    for(int k=min(j1,j2)+1;k<max(j1,j2);k++){
                        if(c[i1][k] != '.'){
                            flag = true;
                            break;
                        }
                    }
                    if(!flag){
                        c[i1][j1] = '.';
                        c[i2][j2] = '.';
                        res += 2;
                        al[i].clear();
                        act = true;
                    }
                }else if(j1 == j2){
                    if(abs(i1-i2) == 1){
                        continue;
                    }
                    bool flag = false;
                    for(int k=min(i1,i2)+1;k<max(i1,i2);k++){
                        if(c[k][j1] != '.'){
                            flag = true;
                            break;
                        }
                    }
                    if(!flag){
                        c[i1][j1] = '.';
                        c[i2][j2] = '.';
                        res += 2;
                        al[i].clear();
                        act = true;
                    }
                }else{
                    int mi = min(i1,i2),ni = max(i1,i2);
                    int mj = min(j1,j2),nj = max(j1,j2);
                    if((i1-i2)*(j1-j2) > 0){
                        bool flag = false;
                        for(int k = mi;k<=ni;k++){
                            if(c[k][mj] != '.' && c[k][mj] != (char)('A' + i)){
                                flag = true;
                                break;
                            }
                        }
                        if(!flag){
                            for(int k = mj;k<=nj;k++){
                                if(c[ni][k] != '.' && c[ni][k] != (char)('A' + i)){
                                    flag = true;
                                    break;
                                }
                            }
                        }
                        if(!flag){
                            c[i1][j1] = '.';
                            c[i2][j2] = '.';
                            res += 2;
                            al[i].clear();
                            act = true;
                            continue;
                        }
                        flag = false;
                        for(int k = mi;k<=ni;k++){
                            if(c[k][nj] != '.' && c[k][nj] != (char)('A' + i)){
                                flag = true;
                                break;
                            }
                        }
                        if(!flag){
                            for(int k = mj;k<=nj;k++){
                                if(c[mi][k] != '.' && c[mi][k] != (char)('A' + i)){
                                    flag = true;
                                    break;
                                }
                            }
                        }
                        if(!flag){
                            c[i1][j1] = '.';
                            c[i2][j2] = '.';
                            res += 2;
                            al[i].clear();
                            act = true;
                        }
                    }else{
                        bool flag = false;
                        for(int k = mi;k<=ni;k++){
                            if(c[k][mj] != '.' && c[k][mj] != (char)('A' + i)){
                                flag = true;
                                break;
                            }
                        }
                        if(!flag){
                            for(int k = mj;k<=nj;k++){
                                if(c[mi][k] != '.' && c[mi][k] != (char)('A' + i)){
                                    flag = true;
                                    break;
                                }
                            }
                        }
                        if(!flag){
                            c[i1][j1] = '.';
                            c[i2][j2] = '.';
                            res += 2;
                            al[i].clear();
                            act = true;
                            continue;
                        }
                        flag = false;
                        for(int k = mi;k<=ni;k++){
                            if(c[k][nj] != '.' && c[k][nj] != (char)('A' + i)){
                                flag = true;
                                break;
                            }
                        }
                        if(!flag){
                            for(int k = mj;k<=nj;k++){
                                if(c[ni][k] != '.' && c[ni][k] != (char)('A' + i)){
                                    flag = true;
                                    break;
                                }
                            }
                        }
                        if(!flag){
                            c[i1][j1] = '.';
                            c[i2][j2] = '.';
                            res += 2;
                            al[i].clear();
                            act = true;
                        }
                    }
                }
            }
        }
        if(!act){
            break;
        }
    }
    printf("%d\n",res);
	return 0;
}

Measured memory_bytes: 3480