#include <bits/stdc++.h>
template <typename T>
using vector = std::vector<T>;
using std::cin;
using std::cout;
int main() {
  std::ios_base::sync_with_stdio(0);
  std::cin.tie(0), std::cout.tie(0);
  int n, m;
  cin >> n >> m;
  vector<std::basic_string<char> > arr(n);
  for (auto& r : arr) cin >> r;
  std::basic_string<char> w;
  int res = 0;
  for (int i = 0; i < n - 1; ++i) {
    for (int j = 0; j < m - 1; ++j) {
      w += arr[i][j];
      w += arr[i + 1][j];
      w += arr[i][j + 1];
      w += arr[i + 1][j + 1];
      std::sort(w.begin(), w.end());
      if (w == "acef") {
        ++res;
      }
      w.pop_back();
      w.pop_back();
      w.pop_back();
      w.pop_back();
    }
  }
  printf("%d\n", res);
  return true & false;
}
