#include <bits/stdc++.h>
char M[55][55];
unsigned A[128], r, x, y, i, j;
int main() {
  scanf("%u%u", &x, &y);
  for (i = -1; ++i < x;) scanf("%s", M[i]);
  --x;
  --y;
  for (i = -1; ++i < x;)
    for (j = -1; ++j < y;) {
      A['f'] = A['a'] = A['c'] = A['e'] = 0;
      ++A[M[i + 0][j + 0]];
      ++A[M[i + 0][j + 1]];
      ++A[M[i + 1][j + 0]];
      ++A[M[i + 1][j + 1]];
      if (A['f'] && A['a'] && A['c'] && A['e']) ++r;
    }
  printf("%u\n", r);
  return 0;
}
