#include using namespace std; inline bool isMas(char a, char b) { return (a == 'M' && b == 'S') || (a == 'S' && b == 'M'); } int main() { ios::sync_with_stdio(0); cin.tie(0); vector lines; string line; while (getline(cin, line) && !line.empty()) { lines.push_back(line); } int n = 0; for (int x = 1; x < lines.size() - 1; x++) { for (int y = 1; y < lines[x].size() - 1; y++) { if (lines[x][y] == 'A' && isMas(lines[x - 1][y - 1], lines[x + 1][y + 1]) && isMas(lines[x - 1][y + 1], lines[x + 1][y - 1])) { n++; } } } cout << n << '\n'; }