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