#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, m, i, j, k, ct = 0;
  cin >> n >> m;
  vector<int> goal = {'f', 'a', 'c', 'e'};
  sort(goal.begin(), goal.end());
  vector<string> s(n);
  for (i = 0; i < n; i++) cin >> s[i];
  for (i = 0; i < n - 1; i++) {
    for (j = 0; j < m - 1; j++) {
      vector<int> ss = {s[i][j], s[i + 1][j], s[i][j + 1], s[i + 1][j + 1]};
      sort(ss.begin(), ss.end());
      if (ss == goal) ct++;
    }
  }
  cout << ct << "\n";
  return 0;
}
