#include <bits/stdc++.h>
using namespace std;
int main() {
  int a, b, maxm = 0;
  string f2 = "";
  cin >> a >> b;
  char arr[a][b];
  for (int t = 0; t < a; t++) {
    for (int p = 0; p < b; p++) {
      cin >> arr[t][p];
    }
  }
  for (int t = 0; t < a - 1; t++) {
    for (int p = 0; p < b - 1; p++) {
      f2 = "";
      f2 += arr[t][p];
      f2 += arr[t + 1][p];
      f2 += arr[t][p + 1];
      f2 += arr[t + 1][p + 1];
      sort(f2.begin(), f2.end());
      if (f2 == "acef") maxm++;
    }
  }
  cout << maxm << endl;
  return 0;
}
