#include <bits/stdc++.h>
using namespace std;
stringstream sss;
int main() {
  int n, m;
  cin >> n >> m;
  char image[n][m];
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      cin >> image[i][j];
    }
  }
  int faces = 0;
  for (int i = 0; i < n - 1; i++) {
    for (int j = 0; j < m - 1; j++) {
      string temp;
      temp.append(1, image[i][j]);
      temp.append(1, image[i + 1][j]);
      temp.append(1, image[i][j + 1]);
      temp.append(1, image[i + 1][j + 1]);
      if (temp.find('f') != string::npos && temp.find('a') != string::npos &&
          temp.find('c') != string::npos && temp.find('e') != string::npos) {
        faces++;
      }
    }
  }
  cout << faces;
  return 0;
}
