#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;

int M, N;
string s[510];
vector<pii> g[26];
int ans = 0;

bool check(int y, int x, int dy, int dx, char ch) {
  if (s[y][x] != '.' && s[y][x] != ch) return false;
  int ny, nx;
  ny = y + dy, nx = x;
  while (true) {
    if (s[ny][nx] == ch) break;
    if (s[ny][nx] != '.') return false;
    ny += dy;
  }
  ny = y, nx = x + dx;
  while (true) {
    if (s[ny][nx] == ch) break;
    if (s[ny][nx] != '.') return false;
    nx += dx;
  }
  return true;
}

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  cin >> M >> N;
  for (int i = 0; i < M; i++) {
    cin >> s[i];
    for (int j = 0; j < N; j++) {
      if (s[i][j] == '.') continue;
      g[s[i][j] - 'A'].emplace_back(i, j);
    }
  }
  bool update = true;
  while (update) {
    update = false;
    for (int i = 0; i < 26; i++) {
      if (g[i].empty()) continue;
      if (abs(g[i][0].first - g[i][1].first) + abs(g[i][0].second - g[i][1].second) == 1) continue;
      int sy, sx;
      int gy, gx;
      int dy, dx;
      tie(sy, sx) = make_tuple(g[i][0].first, g[i][1].second);
      tie(gy, gx) = make_tuple(g[i][1].first, g[i][0].second);
      dy = gy - sy > 0 ? 1 : gy - sy < 0 ? -1 : 0;
      dx = gx - sx > 0 ? 1 : gx - sx < 0 ? -1 : 0;
      if (check(sy, sx, dy, dx, char(i + 'A'))) {
        for (pii p : g[i]) {
          s[p.first][p.second] = '.';
        }
        ans += 2;
        g[i].clear();
        update = true;
        continue;
      }
      tie(sy, sx) = make_tuple(g[i][1].first, g[i][0].second);
      tie(gy, gx) = make_tuple(g[i][0].first, g[i][1].second);
      dy = gy - sy > 0 ? 1 : gy - sy < 0 ? -1 : 0;
      dx = gx - sx > 0 ? 1 : gx - sx < 0 ? -1 : 0;
      if (check(sy, sx, dy, dx, char(i + 'A'))) {
        for (pii p : g[i]) {
          s[p.first][p.second] = '.';
        }
        ans += 2;
        g[i].clear();
        update = true;
        continue;
      }
    }
  }
  cout << ans << endl;

  return 0;
}
