#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m, res = 0;
  cin >> n >> m;
  char arr[n][m];
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      cin >> arr[i][j];
    }
  }
  string temp, face = "acef";
  for (int i = 0; i < n - 1; i++) {
    for (int j = 0; j < m - 1; j++) {
      temp = "";
      temp += arr[i][j];
      temp += arr[i + 1][j];
      temp += arr[i][j + 1];
      temp += arr[i + 1][j + 1];
      sort(temp.begin(), temp.end());
      if (temp == face) {
        res++;
      }
    }
  }
  cout << res << endl;
  return 0;
}
