#include <bits/stdc++.h>
using namespace std;
const int MXN = 64;
char f[MXN][MXN];
int h, w;
int n;
static int ad(char c) {
  int cv = 0;
  if (c == 'f') cv |= 1;
  if (c == 'a') cv |= 2;
  if (c == 'c') cv |= 4;
  if (c == 'e') cv |= 8;
  return cv;
}
int solve() {
  int ans = 0;
  for (int i = 1; i < h; i++) {
    for (int j = 1; j < w; j++) {
      int fc =
          ad(f[i][j]) | ad(f[i - 1][j]) | ad(f[i][j - 1]) | ad(f[i - 1][j - 1]);
      if (fc == 15) ans++;
    }
  }
  return ans;
}
int main() {
  while (scanf("%d %d", &h, &w) == 2) {
    for (int i = 0; i < h; i++) scanf("%s", f[i]);
    printf("%d\n", solve());
  }
  return 0;
}
