#include <bits/stdc++.h>
using namespace std;
int main() {
  string str[100];
  int n, m;
  cin >> n >> m;
  for (size_t index = 0; index < n; ++index) {
    cin >> str[index];
  }
  int answer = 0;
  for (size_t i = 0; i + 1 < n; ++i) {
    for (size_t j = 0; j + 1 < m; ++j) {
      set<char> st;
      for (size_t qi = 0; qi < 2; ++qi) {
        for (size_t qj = 0; qj < 2; ++qj) {
          st.insert(str[i + qi][j + qj]);
        }
      }
      if (st.count('f') && st.count('a') && st.count('c') && st.count('e')) {
        ++answer;
      }
    }
  }
  cout << answer;
  return 0;
}
