#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
void solve() {
  int n, m;
  cin >> n >> m;
  vector<string> grid(n);
  for (auto i = 0; i < n; ++i) {
    cin >> grid[i];
  }
  int faces = 0;
  for (auto i = 0; i < n; ++i) {
    for (auto j = 0; j < m; ++j) {
      string letters = "";
      if (i + 1 < n && j + 1 < m) {
        letters.push_back(grid[i][j]);
        letters.push_back(grid[i + 1][j]);
        letters.push_back(grid[i][j + 1]);
        letters.push_back(grid[i + 1][j + 1]);
        sort(letters.begin(), letters.end());
        if (letters == "acef") {
          faces++;
        }
      }
    }
  }
  cout << faces << endl;
}
int32_t main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  int test = 1;
  while (test--) {
    solve();
  }
  return 0;
}
