#include <bits/stdc++.h>
using namespace std;
char s[52][52];
int main() {
  int n, m;
  cin >> n >> m;
  int ans = 0;
  for (int i = 0; i < n; i++) cin >> s[i];
  for (int i = 0; i < n - 1; i++) {
    for (int j = 0; j < m - 1; j++) {
      vector<char> a;
      a.push_back(s[i][j]);
      a.push_back(s[i][j + 1]);
      a.push_back(s[i + 1][j + 1]);
      a.push_back(s[i + 1][j]);
      sort(a.begin(), a.end());
      if (a[0] == 'a' && a[1] == 'c' && a[2] == 'e' && a[3] == 'f') ans++;
    }
  }
  cout << ans << endl;
  return 0;
}
