#include <bits/stdc++.h>
using namespace std;
using ll = long long;
void redir() {}
bool contains_face(size_t i, size_t j, const vector<string> &lines) {
  unordered_set<char> cs;
  if (i >= 0 && i + 1 < lines.size()) {
    if (j >= 0 && j + 1 < lines[i].length()) {
      cs.insert(lines[i][j]);
      cs.insert(lines[i + 1][j]);
      cs.insert(lines[i][j + 1]);
      cs.insert(lines[i + 1][j + 1]);
    } else {
      return false;
    }
  } else {
    return false;
  }
  return cs.find('f') != cs.end() && cs.find('a') != cs.end() &&
         cs.find('c') != cs.end() && cs.find('e') != cs.end();
}
int solve() {
  int n, m;
  cin >> n >> m;
  vector<string> lines(n);
  for (string &line : lines) {
    cin >> line;
  }
  int count = 0;
  for (auto i = 0; i < n; i++) {
    for (auto j = 0; j < m; j++) {
      if (contains_face(i, j, lines)) {
        count++;
      }
    }
  }
  return count;
}
int main() {
  redir();
  cout << solve();
}
