#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

char c[3009][3009]; int H, W, p[3009], dp[3009][3];
bool useda[3009], usedb[3009];

int solve() {
	for (int i = 0; i < 3009; i++) { dp[i][0] = 0; dp[i][1] = 0; dp[i][2] = 0; }

	for (int i = H; i >= 1; i--) {
		if (useda[i] == true) {
			for (int j = 0; j <= 2; j++) dp[i - 1][2] = max(dp[i - 1][2], dp[i][j] + 1);
		}
		if (p[i] >= 1 && usedb[p[i]] == true) dp[i - 1][0] = max(dp[i - 1][0], dp[i][0] + 1);
		dp[i - 1][0] = max(dp[i - 1][0], max(dp[i][0], dp[i][1]));
		dp[i - 1][1] = max(dp[i - 1][1], dp[i][2]);
	}
	return max({ dp[0][0], dp[0][1], dp[0][2] });
}

int main() {
	cin >> H >> W;
	for (int i = 1; i <= H; i++) {
		for (int j = 1; j <= W; j++) {
			cin >> c[i][j];
		}
	}

	int ans = 0;
	for (int i = 2; i <= H + W; i++) {
		for (int j = 1; j <= H; j++) useda[j] = false;
		for (int j = 1; j <= W; j++) usedb[j] = false;
		for (int j = 1; j <= H; j++) p[j] = 0;

		vector<pair<int, int>> G;
		for (int j = 1; j <= H; j++) {
			int x = j, y = i - j;
			if (1 <= y && y <= W) { G.push_back(make_pair(x, y)); p[x] = y; }
		}
		for (int j = 0; j < G.size(); j++) {
			int px = G[j].first, py = G[j].second;
			if (c[px][py] == 'R' && c[px][py + 1] == 'G' && c[px][py + 2] == 'W') useda[px] = true;
			if (c[px][py] == 'R' && c[px + 1][py] == 'G' && c[px + 2][py] == 'W') usedb[py] = true;
		}

		int Z = solve();
		ans += Z;
	}
	cout << ans << endl;
	return 0;
}
