#include <bits/stdc++.h>
using namespace std;
const int SIZE = 1e2 + 5;
int main() {
  int n, m, c;
  string s[SIZE], extract, f;
  c = 0, f = "acef";
  cin >> n >> m;
  for (int i = 0; i < n; i++) cin >> s[i];
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      extract.push_back(s[i][j]);
      extract.push_back(s[i + 1][j]);
      extract.push_back(s[i][j + 1]);
      extract.push_back(s[i + 1][j + 1]);
      sort(extract.begin(), extract.end());
      if (extract == f) c++;
      extract.clear();
    }
  }
  cout << c << endl;
  return 0;
}
