#include <bits/stdc++.h>
using namespace std;
int n, m;
char s[100][100];
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 0; i < n; ++i) scanf("%s", s[i]);
  int ans = 0;
  for (int i = 0; i < n - 1; ++i)
    for (int j = 0; j < m - 1; ++j) {
      vector<char> vec;
      vec.push_back(s[i][j]);
      vec.push_back(s[i + 1][j]);
      vec.push_back(s[i][j + 1]);
      vec.push_back(s[i + 1][j + 1]);
      sort(vec.begin(), vec.end());
      ;
      if (vec[0] == 'a' && vec[1] == 'c' && vec[2] == 'e' && vec[3] == 'f')
        ans++;
    }
  printf("%d\n", ans);
}
