#include <bits/stdc++.h>
using namespace std;
string s = "acef";
string ss;
char a[55][55];
int main() {
  int ans = 0;
  int n, m;
  cin >> n >> m;
  for (int i = 1; i <= n; i++) {
    scanf("%s", a[i] + 1);
  }
  for (int i = 1; i <= n - 1; i++) {
    for (int j = 1; j <= m - 1; j++) {
      ss = "";
      ss += a[i][j];
      ss += a[i][j + 1];
      ss += a[i + 1][j];
      ss += a[i + 1][j + 1];
      sort(ss.begin(), ss.end());
      if (ss == s) {
        ans++;
      }
    }
  }
  cout << ans << endl;
  return 0;
}
