#include <bits/stdc++.h>
using namespace std;
int main(void) {
  int n, m;
  cin >> n >> m;
  int count = 0;
  char a[n][m];
  bool flag = false;
  int i, j;
  for (i = 0; i < n; i++) {
    for (j = 0; j < m; j++) cin >> a[i][j];
  }
  for (i = 0; i < n - 1; i++) {
    for (j = 0; j < m - 1; j++) {
      if ((a[i][j] * a[i + 1][j] * a[i][j + 1] * a[i + 1][j + 1]) ==
          'f' * 'a' * 'c' * 'e') {
        count++;
      }
    }
  }
  cout << count;
  return 0;
}
