import std.stdio;
import std.ascii;
import std.c.stdio;
import std.range;
import std.array;
import std.functional;
import std.algorithm;
import std.conv;
import std.container;
import std.math;
import std.numeric;
import std.string;
import std.c.string;
import std.regex;
import std.typecons;

struct P {
    int y, x;
}

void main() {
    int H, W;
    scanf("%d %d\n", &H, &W);
    auto F = cast(char[][])(new string[H]);
    foreach (ref L; F) L = cast(char[])readln.chomp;

    auto X = new P[][26];
    foreach (i; 0 .. H) {
        foreach (j; 0 .. W) {
            if (F[i][j] == '.') continue;
            X[ F[i][j] - 'A' ] ~= P(i, j);
        }
    }
    //foreach (i; 0 .. 26) writeln(cast(char)('A' + i), " ", X[i]);

    bool check(P a, P b, int dy, int dx) {
        //writeln(a, " -> ", b, [dy, dx]);
        a.y += dy;
        a.x += dx;
        while (a != b) {
            if (F[a.y][a.x].isUpper) return false;
            a.y += dy;
            a.x += dx;
            //writeln(a);
        }
        return true;
    }

    int Ans = 0;
    auto used = new bool[26];
    foreach (t; 0 .. 26) {
        foreach (i; 0 .. 26) {
            if (X[i].empty) continue;
            if (used[i]) continue;
            auto a = X[i][0], b = X[i][1];
            int y = b.y - a.y,
                x = b.x - a.x;
            if (y == 0) {
                if (abs(x) == 1) continue;
                if (check(a, b, 0, x / abs(x))) {
                    F[a.y][a.x] = '.';
                    F[b.y][b.x] = '.';
                    Ans += 2;
                    used[i] = true;
                }
            } else if (x == 0) {
                if (abs(y) == 1) continue;
                if (check(a, b, y / abs(y), 0)) {
                    F[a.y][a.x] = '.';
                    F[b.y][b.x] = '.';
                    Ans += 2;
                    used[i] = true;
                }
            } else {
                auto p = P(a.y, b.x),
                     q = P(b.y, a.x);
                if ( (F[p.y][p.x] == '.' && 
                            check(a, p, 0, x / abs(x)) && 
                            check(p, b, y / abs(y), 0)) ||
                     (F[q.y][q.x] == '.' &&
                            check(a, q, y / abs(y), 0) && 
                            check(q, b, 0, x / abs(x))) ) {
                    F[a.y][a.x] = '.';
                    F[b.y][b.x] = '.';
                    Ans += 2;
                    used[i] = true;
                }
            }
        }
    }
    writeln(Ans);
}