#include <bits/stdc++.h>
using namespace std;
string a[200];
int mn[200];
int main() {
  int n, m;
  cin >> n >> m;
  for (int i = 1; i <= n; ++i) cin >> a[i];
  int cou = 0;
  for (int i = 1; i <= n - 1; ++i) {
    for (int j = 0; j <= m - 2; ++j) {
      mn['f'] = mn['a'] = mn['c'] = mn['e'] = 0;
      mn[a[i][j]]++, mn[a[i + 1][j]]++, mn[a[i][j + 1]]++,
          mn[a[i + 1][j + 1]]++;
      if (mn['f'] == 1 && mn['a'] == 1 && mn['c'] == 1 && mn['e'] == 1) cou++;
    }
  }
  cout << cou << '\n';
  return 0;
}
