Problem: Training is indispensable for achieving good results at ICPC. Rabbit wants to win at ICPC, so he decided to practice today as well.

Today's training is to quickly solve popular puzzles and train your instantaneous power. Today's challenge is a puzzle of colorful tiles lined up and erasing them well.

In the initial state, tiles are placed on some squares on the grid. Each tile is colored. After the game starts, the player can perform the operations shown in the following procedure many times.

1. Select one square without tiles and hit that square.
2. Follow from the hit square to the top, and pay attention to the tile when you reach the square where the tile is placed. If you get to the edge of the board without the squares on which the tiles are placed, you will not pay attention to anything.
3. Perform the same operation from the square you hit to the bottom, left, and right. Up to 4 tiles will be the focus of attention.
4. If any of the tiles of interest have the same color, remove those tiles from the board. If there are two pairs of tiles of the same color, remove both.
5. The score will be the same as the number of tiles removed.
6. Stop paying attention.



For example, consider the following situation. The squares without tiles are periods, and the tile colors are represented by uppercase letters.


..A ......
....... B ..
..........
..B ......
..A.CC ....


Now consider the operation of hitting the squares in the second row from the top and the third column from the left. Since there are three tiles of interest, `A`,` B`, and `B`, the two of` B` disappear and the board becomes as follows, and two points are obtained.


..A ......
..........
..........
..........
..A.CC ....


If this puzzle is slow, the time will run out, and you will not be able to see part of the board and you will not know how much training you lacked. Two tiles of each color are placed, but it is not always possible to erase all of them, so let the program calculate the maximum score in advance.



Input


M N
C1,1 C1,2 ... C1, N
C2,1 C2,2 ... C2, N
...
CM, 1CM, 2 ... CM, N


The integers M and N indicate that the board is a grid of vertical M x horizontal N. Ci and j are uppercase letters or periods (`.`), And for the cells in the i-th row from the top and the j-th column from the left, the uppercase letters indicate the color of the tiles placed, and the period indicates the color of the tile. Indicates that no tile is placed on this square.

Satisfy 1 ≤ M ≤ 500 and 1 ≤ N ≤ 500. Each uppercase letter appears as 0 or 2 as you type.

Output

Output the maximum score on one line.

Examples

Input

5 10
..A.......
.......B..
..........
..B.......
..A.CC....


Output

4


Input

3 3
ABC
D.D
CBA


Output

4


Input

5 7
NUTUBOR
QT.SZRQ
SANAGIP
LMDGZBM
KLKIODP


Output

34

Solution (in CPP):

Solution:
#include <bits/stdc++.h>
using namespace std;
#define int long long   // <-----!!!!!!!!!!!!!!!!!!!

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#define rrep2(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define all(a) (a).begin(),(a).end()

typedef long long ll;
typedef pair<int, int> Pii;
typedef tuple<int, int, int> TUPLE;
typedef vector<int> V;
typedef vector<V> VV;
typedef vector<VV> VVV;
typedef vector<vector<int>> Graph;
const int inf = 1e9;
const int mod = 1e9 + 7;

enum { X, Y, CHAR };
typedef vector<int> Tile;

int H, W;
vector<string> s;

// N, E, S, W
const int dx[4] = {-1, 0,  1,  0};
const int dy[4] = { 0, 1,  0, -1};

inline bool inside(int x, int y) {
    return 0 <= x && x < H && 0 <= y && y < W;
}

Tile findNearestTile(int x, int y, int k) {
    if (!inside(x, y) || s[x][y] == '#') return Tile{-1, -1, -1};
    if (isalpha(s[x][y])) return Tile{x, y, s[x][y] - 'A'};
    return findNearestTile(x + dx[k], y + dy[k], k);
}

bool hit(int sx, int sy) {
    if (s[sx][sy] == '#') return false;
    if (isalpha(s[sx][sy])) {
        rep(k, 4) {
            int nx = sx + dx[k], ny = sy + dy[k];
            if (!inside(nx, ny)) continue;
            if (s[sx][sy] == s[nx][ny]) {
                s[sx][sy] = '.';
                s[nx][ny] = '.';
                return true;
            }
        }
        return false;
    }

    rep(start, 4) {
        Tile tile1{-1, -1, -1};
        rep(k, 4) {
            Tile tile2 = findNearestTile(sx, sy, (k + start) % 4);
            if (tile2[CHAR] == -1) {
                continue;
            } else if (tile1[CHAR] == -1) {
                tile1 = tile2;
            } else if (tile1[CHAR] == tile2[CHAR]) {
                s[tile1[X]][tile1[Y]] = '.';
                s[tile2[X]][tile2[Y]] = '.';
                return true;
            }
        }
    }
    return false;
}

bool search() {
    rep(i, H) {
        rep(j, W) {
            if (hit(i, j)) {
                return true;
            }
        }
    }
    return false;
}

bool checkCompress(string line) {
    for (const auto& c : line) {
        if (c != '.') return false;
    }
    return true;
}

void compress(vector<string> &s) {
    for (int i = 0; i < s.size(); ) {
        if (checkCompress(s[i])) {
            s.erase(s.begin() + i);
        } else {
            i++;
        }
    }
}

void rot(vector<string> &s) {
    vector<string> t(s[0].size(), "");
    rep(i, s.size()) rep(j, s[0].size()) {
        t[j] += s[i][j];
    }
    s = t;
}

signed main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);

    cin >> H >> W;
    s.resize(H);
    rep(i, H) cin >> s[i];

    rep(x, H) {
        rep(y, W) {
            rep(k, 4) {
                int nx = x + dx[k], ny = y + dy[k];
                if (!inside(nx, ny)) continue;
                if (isalpha(s[x][y]) && s[x][y] == s[nx][ny]) {
                    s[x][y] = '#';
                    s[nx][ny] = '#';
                }
            }
        }
    }

    compress(s);
    if (s.empty()) {
        cout << 0 << endl;
        return 0;
    }
    rot(s);
    compress(s);
    rot(s);

    H = s.size(), W = s[0].size();

    int ans = 0;
    while (search()) {
        ans += 2;
    }

    cout << ans << endl;

}