#include<bits/stdc++.h>
using namespace std;

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

struct info{

    int i;
    int j;
    char color;
    info(){}
    info(int i, int j, char c):i(i),j(j),color(c){}
};

int main(){

    int h, w; cin >> h >> w;
    vector<vector<char> > a(h, vector<char> (w, '.'));
    
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            cin >> a[i][j];
        }
    }

    int ans = 0;

    while(1){
        bool flag = false;

        for(int i = 0; i < h; i++){
            for(int j = 0; j < w; j++){
                if(a[i][j] != '.') continue;

                //cout << i << " " << j << endl;

                vector<info> tyakumoku;
                for(int ii = i + 1; ii < h; ii++){
                    if(a[ii][j] != '.'){
                        tyakumoku.push_back(info(ii, j, a[ii][j]));
                        break;
                    }
                }
                for(int ii = i - 1; ii >= 0; ii--){
                    if(a[ii][j] != '.'){
                        tyakumoku.push_back(info(ii, j, a[ii][j]));
                        break;
                    }
                }
                for(int jj = j + 1; jj < w; jj++){
                    if(a[i][jj] != '.'){
                        tyakumoku.push_back(info(i, jj, a[i][jj]));
                        break;
                    }
                }
                for(int jj = j - 1; jj >= 0; jj--){
                    if(a[i][jj] != '.'){
                        tyakumoku.push_back(info(i, jj, a[i][jj]));
                        break;
                    }
                }

                int T = (int)tyakumoku.size();
                //cout << i << " " << j << endl;
                //for(int l = 0; l > T; l++) cout << tyakumoku[l].i << " " << tyakumoku[l].j << " " << tyakumoku[l].color << endl;
                //cout << endl;

                //cout << T << endl;

                //cout << "ho" << endl;
                for(int ii = 0; ii < T; ii++){
                    for(int jj = ii + 1; jj < T; jj++){
                        
                        if(tyakumoku[ii].color == tyakumoku[jj].color){
                            //cout << i << " " << j << endl;
                            //cout << tyakumoku[ii].i << " " << tyakumoku[ii].j << " " << tyakumoku[ii].color << endl;
                            //cout << tyakumoku[jj].i << " " << tyakumoku[jj].j << " " << tyakumoku[jj].color << endl;
                            //cout << "ok" << ii << " " << jj << endl;
                            //cout << "ok" << endl;
                            ans += 2;
                            flag = true;
                            a[tyakumoku[ii].i][tyakumoku[ii].j] = '.';
                            a[tyakumoku[jj].i][tyakumoku[jj].j] = '.';
                            
                        }
                    }
                }

                //cout << "hoga" << endl;
            }
        }

        
        //cout << endl;
        //cout << ans << endl;
        /*for(int i = 0; i < h; i++){
            for(int j = 0; j < w; j++){
                cout << a[i][j] << " ";
            }
            cout << endl;
        }*/
        

        if(!flag) break;
    }

    cout << ans << endl;

    return 0;
}




Measured memory_bytes: 3272