#include <bits/stdc++.h>
using namespace std;
int main() {
  unsigned int n, m;
  cin >> n >> m;
  vector<vector<char> > pic(n, vector<char>(m));
  unsigned int count = 0;
  for (unsigned int i = 0; i < n; i++) {
    for (unsigned int j = 0; j < m; j++) {
      cin >> pic[i][j];
    }
  }
  for (unsigned int i = 0; i < n - 1; i++) {
    for (unsigned int j = 0; j < m - 1; j++) {
      set<char> sq;
      sq.insert(pic[i][j]);
      sq.insert(pic[i + 1][j]);
      sq.insert(pic[i][j + 1]);
      sq.insert(pic[i + 1][j + 1]);
      if (sq.find('f') != sq.end() && sq.find('a') != sq.end() &&
          sq.find('c') != sq.end() && sq.find('e') != sq.end()) {
        count++;
      }
    }
  }
  cout << count << '\n';
  return 0;
}
