#include <bits/stdc++.h>
using namespace std;
char a[51][51];
int n, m, ok1, ok2, ok3, ok4;
int main() {
  cin >> n >> m;
  int cnt = 0;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  for (int i = 0; i < n - 1; i++) {
    for (int j = 0; j < m - 1; j++) {
      ok1 = ok2 = ok3 = ok4 = 0;
      for (int l = 0; l < 2; l++) {
        for (int k = 0; k < 2; k++) {
          if (a[i + k][j + l] == 'f') {
            ok1 = 1;
          }
          if (a[i + k][j + l] == 'a') {
            ok2 = 1;
          }
          if (a[i + k][j + l] == 'c') {
            ok3 = 1;
          }
          if (a[i + k][j + l] == 'e') {
            ok4 = 1;
          }
        }
      }
      if (ok1 && ok2 && ok3 & ok4) {
        cnt++;
      }
    }
  }
  cout << cnt;
  return 0;
}
