#include <iostream>
#include <algorithm>
#include <numeric>
#include <vector>
#include <cassert>
#include <string>
#include <memory.h>
#include <queue>
#include <cstdio>
#include <cstdlib>
#include <set>
#include <map>
#include <cctype>
#include <iomanip>
#include <sstream>
#include <cctype>
#include <fstream>
#include <cmath>
using namespace std;

#define REP2(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define REP(i, n) REP2(i, 0, n)
#define ALL(c) (c).begin(), (c).end()
#define ITER(c) __typeof((c).begin())
#define PB(e) push_back(e)
#define FOREACH(i, c) for(ITER(c) i = (c).begin(); i != (c).end(); ++i)
#define MP(a, b) make_pair(a, b)
#define PARITY(n) ((n) & 1)

typedef long long ll;
typedef pair<ll, ll> P;
const int INF = 1000 * 1000 * 1000 + 7;
const double EPS = 1e-10;

int main(){
  int N, M;
  cin >> N >> M;
  vector<string> field(N);
  REP(i, N) cin >> field[i];
  
  vector<int> rows;
  vector<int> cols;
  
  REP(i, N)REP(j, M)if(isalpha(field[i][j])){
    REP(k, 3){
      rows.push_back(i+k-1);
      cols.push_back(j+k-1);
    }
  }

  sort(ALL(rows));
  sort(ALL(cols));
  rows.erase(unique(ALL(rows)), rows.end());
  cols.erase(unique(ALL(cols)), cols.end());
  
  vector<string> board(rows.size(), string(cols.size(), '.'));
  
  REP(i, N)REP(j, M)if(isalpha(field[i][j])){
    int r = lower_bound(ALL(rows), i) - rows.begin();
    int c = lower_bound(ALL(cols), j) - cols.begin();
    board[r][c] = field[i][j];
  }
  
  N = rows.size();
  M = cols.size();
  
  int res = 0;
  int dr[4] = {0, -1, 0, 1};
  int dc[4] = {1, 0, -1, 0};
  bool update = true;
  
  while(update){
    update = false;
    
    REP(r, N)REP(c, M)if(board[r][c] == '.'){
      vector<int> t_row;
      vector<int> t_col;
      REP(i, 4){
        int r2 = r + dr[i];
        int c2 = c + dc[i];
        while(0 <= r2 && r2 < N && 0 <= c2 && c2 < M && board[r2][c2] == '.'){
          r2 += dr[i];
          c2 += dc[i];
        }
        
        if(0 <= r2 && r2 < N && 0 <= c2 && c2 < M){
          t_row.push_back(r2);
          t_col.push_back(c2);
        }
        
        REP(i, 26){
          int c = 0;
          REP(j, t_row.size()) if(board[t_row[j]][t_col[j]] == 'A' + i) c++;
          if(c >= 2){
            update = true;
            res += c;
            REP(j, t_row.size()){
              char &tile = board[t_row[j]][t_col[j]];
              if(tile == 'A' + i) tile = '.';
            }
          }
        }
      }
    }
  }
  
  cout << res << endl;
  return 0;
}