#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1000000;
const int MOD = 1000000007;
const int INF = ((1 << 31) - 1);
int first, second, sol;
char c[55][55];
char cc[5];
bool f(int cx, int cy) {
  cc[0] = c[cx][cy];
  cc[1] = c[cx + 1][cy];
  cc[2] = c[cx][cy + 1];
  cc[3] = c[cx + 1][cy + 1];
  sort(cc, cc + 4);
  if (cc[0] == 'a' && cc[1] == 'c' && cc[2] == 'e' && cc[3] == 'f') return 1;
  return 0;
}
int main() {
  scanf("%d%d", &first, &second);
  for (int i = (0), _for = (first); i < _for; ++i) scanf("%s", &c[i][0]);
  for (int i = (0), _for = (first - 1); i < _for; ++i)
    for (int j = (0), _for = (second - 1); j < _for; ++j) sol += f(i, j);
  printf("%d", sol);
  return 0;
}
