#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m, ans = 0;
  string im[55];
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    cin >> im[i];
  }
  for (int i = 0; i < n - 1; i++) {
    for (int j = 0; j < m - 1; j++) {
      int occ[256];
      fill(occ, occ + 256, 0);
      occ[im[i][j]]++;
      occ[im[i + 1][j]]++;
      occ[im[i + 1][j + 1]]++;
      occ[im[i][j + 1]]++;
      if (occ['f'] && occ['a'] && occ['c'] && occ['e']) {
        ans++;
      }
    }
  }
  cout << ans << endl;
  return 0;
}
