#include <bits/stdc++.h>
using namespace std;
const int maxn = 55;
string str[maxn];
int n, m, ans = 0;
char word[4];
int main() {
  cin >> n >> m;
  for (int i = 0; i < n; ++i) cin >> str[i];
  for (int i = 0; i < n - 1; ++i) {
    for (int j = 0; j < m - 1; ++j) {
      word[0] = str[i][j], word[1] = str[i][j + 1], word[2] = str[i + 1][j],
      word[3] = str[i + 1][j + 1];
      sort(word, word + 4);
      if (word[0] == 'a' && word[1] == 'c' && word[2] == 'e' &&
          word[3] == 'f') {
        ++ans;
      }
    }
  }
  cout << ans << endl;
  return 0;
}
