#include <bits/stdc++.h>
using namespace std;
const int INF = 1 << 30;
const double EPS = 1e-12;
int main() {
  ios_base::sync_with_stdio(0);
  int n, m;
  cin >> n >> m;
  vector<string> v(n);
  for (int i = 0; i < n; i++) cin >> v[i];
  int ans = 0;
  for (int i = 0; i + 1 < n; i++) {
    for (int j = 0; j + 1 < m; j++) {
      vector<int> meh(500, 0);
      meh[v[i][j]]++;
      meh[v[i + 1][j]]++;
      meh[v[i][j + 1]]++;
      meh[v[i + 1][j + 1]]++;
      if (meh['f'] && meh['a'] && meh['c'] && meh['e']) ans++;
    }
  }
  cout << ans << "\n";
}
