#include <bits/stdc++.h>
using namespace std;
string mp[100], tmp;
int main() {
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < n; i++) cin >> mp[i];
  int cnt = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (i + 1 >= n) continue;
      if (j + 1 >= m) continue;
      tmp = "";
      tmp += mp[i][j];
      tmp += mp[i][j + 1];
      tmp += mp[i + 1][j];
      tmp += mp[i + 1][j + 1];
      sort(tmp.begin(), tmp.end());
      if (tmp == "acef") cnt++;
    }
  }
  cout << cnt << endl;
}
