#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;

const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

map<int, int> compress(vector<int>& unzip) {
  map<int, int> zip;
  for (auto x : unzip) REP(d, 3) zip[x + d - 1] = -1;
  int idx = 0;
  unzip = vector<int>();
  for (auto& p : zip) {
    unzip.push_back(p.first);
    p.second = idx;
    idx++;
  }
  return zip;
}

int main() {
  int m, n;
  cin >> m >> n;
  vector<string> c(m);
  REP(i, m) cin >> c[i];

////////////////////////////////////////
  vector<int> xs, ys;
  vector<char> cs;
  REP(i, m) REP(j, n) {
    if (c[i][j] == '.') continue;
    xs.push_back(i);
    ys.push_back(j);
    cs.push_back(c[i][j]);
  }
  vector<int> uzx(xs), uzy(ys);
  auto zx = compress(uzx);
  auto zy = compress(uzy);
  m = zx.size();
  n = zy.size();
  c = vector<string>(m, string(n, '.'));
  REP(k, cs.size()) {
    int x = xs[k];
    int y = ys[k];
    c[zx[x]][zy[y]] = cs[k];
  }
////////////////////////////////////////

  int ans = 0;
  while (true) {
    int sum = 0;
    REP(i, m) REP(j, n) {
      if (c[i][j] != '.') continue;
      vector<int> x(4, i), y(4, j);
      REP(k, 4) {
        while (true) {
          if (c[x[k]][y[k]] != '.') break;
          int tx = x[k] + dx[k];
          int ty = y[k] + dy[k];
          if (tx < 0 || m <= tx || ty < 0 || n <= ty) break;
          x[k] += dx[k];
          y[k] += dy[k];
        }
      }
      REP(k, 4) REP(l, 4) {
        if (k >= l) continue;
        if (c[x[k]][y[k]] != '.' && c[x[k]][y[k]] == c[x[l]][y[l]]) {
          sum += 2;
          c[x[k]][y[k]] = '.';
          c[x[l]][y[l]] = '.';
        }
      }
    }
    if (sum == 0) break;
    ans += sum;
  }
  cout << ans << endl;
}

