#include <bits/stdc++.h>
using namespace std;
char q[50][51];
bool tst(unsigned int r, unsigned int c) {
  bool cf = false, ca = false, cc = false, ce = false;
  for (unsigned int i = 0; i < 2; ++i) {
    for (unsigned int j = 0; j < 2; ++j) {
      switch (q[r + i][c + j]) {
        case 'f':
          cf = true;
          break;
        case 'a':
          ca = true;
          break;
        case 'c':
          cc = true;
          break;
        case 'e':
          ce = true;
          break;
      }
    }
  }
  return cf && ca && cc && ce;
}
int main(int argc, char* argv[]) {
  unsigned int n, m;
  cin >> n >> m;
  for (unsigned int i = 0; i < n; ++i) cin >> q[i];
  unsigned int r = 0;
  for (unsigned int i = 0; i < n - 1; ++i) {
    for (unsigned int j = 0; j < m - 1; ++j) {
      if (tst(i, j)) ++r;
    }
  }
  cout << r << endl;
  return 0;
}
