#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  char img[n][m];
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++) cin >> img[i][j];
  int cont = 0;
  for (int i = 0; i < n - 1; i++) {
    for (int j = 0; j < m - 1; j++) {
      map<char, bool> mark;
      mark[img[i][j]] = true;
      mark[img[i][j + 1]] = true;
      mark[img[i + 1][j]] = true;
      mark[img[i + 1][j + 1]] = true;
      if (mark['f'] && mark['a'] && mark['c'] && mark['e']) cont++;
    }
  }
  cout << cont << "\n";
  return 0;
}
