#include <bits/stdc++.h>
using namespace std;
template <class _T>
inline string tostr(const _T& a) {
  ostringstream os("");
  os << a;
  return os.str();
}
int N, M;
bool val(int x, int y) {
  if (x < 0 || x >= N || y < 0 || y >= M) return 0;
  return 1;
}
set<string> s;
char grid[60][60];
bool mark[200];
int main(int argc, char const* argv[]) {
  scanf("%d %d", &N, &M);
  long long int ans = 0;
  for (int i = (0), __ = (N); i < __; i++) scanf("%s", grid[i]);
  for (int i = (0), __ = (N); i < __; i++)
    for (int j = (0), __ = (M); j < __; j++) {
      if (i + 1 < N && j + 1 < M) {
        memset(mark, 0, sizeof mark);
        mark[grid[i][j]] = 1;
        mark[grid[i + 1][j]] = 1;
        mark[grid[i][j + 1]] = 1;
        mark[grid[i + 1][j + 1]] = 1;
        if (mark['f'] && mark['a'] && mark['c'] && mark['e']) ans++;
      }
    }
  printf("%I64d\n", ans);
  return 0;
}
