#include<iostream>
using namespace std;

string grid[500];
int posy[26][2],posx[26][2];
int pos[26][2][2];
bool use[26];
int n,m;
int res;

bool cluck(int y,int x,int z){
  int k;
  int cnt[26];
  for(int i=0;i<26;i++)cnt[i] = 0;

  k = 1;
  while(y+k<n && grid[y+k][x] == '.')k++;
  if(y+k<n)cnt[grid[y+k][x]-'A']++;

  k = 1;
  while(x+k<m && grid[y][x+k] == '.')k++;
  if(x+k<m)cnt[grid[y][x+k]-'A']++;

  k = 1;
  while(y-k>=0 && grid[y-k][x] == '.')k++;
  if(y-k>=0)cnt[grid[y-k][x]-'A']++;

  k = 1;
  while(x-k>=0 && grid[y][x-k] == '.')k++;
  if(x-k>=0)cnt[grid[y][x-k]-'A']++;

  if(cnt[z]==2){
    res += 2;
    grid[posy[z][0]][posx[z][0]] ='.';
    grid[posy[z][1]][posx[z][1]] ='.';
    return true; 
  }
  return false;
}

int main(){
  cin >> n >> m;
  for(int i=0;i<n;i++)cin >> grid[i];

  for(int i=0;i<26;i++){
    posy[i][0] = -1;
    posx[i][0] = -1;
    posy[i][1] = -1;
    posx[i][1] = -1;
  }

  for(int i=0;i<n;i++){
    for(int j=0;j<m;j++){
      if(grid[i][j] != '.'){
	if(posy[grid[i][j]-'A'][0]<0){
	  posy[grid[i][j]-'A'][0] = i;
	  posx[grid[i][j]-'A'][0] = j;
	}else{
	  posy[grid[i][j]-'A'][1] = i;
	  posx[grid[i][j]-'A'][1] = j;
	}
      }
    }
  }

  res = 0;
  while(1){
    bool f = false;
    for(int i=0;i<26;i++){
      if(posy[i][0] == posy[i][1]){
	int s = min(posx[i][0],posx[i][1]),g = max(posx[i][0],posx[i][1]);
	for(int j=s+1;j<g;j++){
	  if(grid[posy[i][0]][j]=='.')f |= cluck(posy[i][0],j,i);
	}
      }else if(posx[i][0] == posx[i][1]){
	int s = min(posy[i][0],posy[i][1]),g = max(posy[i][0],posy[i][1]);
	for(int j=s+1;j<g;j++){
	  if(grid[j][posx[i][0]]=='.')f |= cluck(j,posx[i][0],i);
	}
      }else{
	if(grid[posy[i][0]][posx[i][1]] == '.')f |= cluck(posy[i][0],posx[i][1],i);
	if(grid[posy[i][1]][posx[i][0]] == '.')f |= cluck(posy[i][1],posx[i][0],i);
      }
    }
    if(!f)break;
  }

  cout << res << endl;
}