#include <bits/stdc++.h>
using namespace std;
const double eps = 1e-9;
const int MaxN = int(1e5) + 256;
const int MOD = int(1e9) + 7;
inline int nextInt() {
  int s = 1, x = 0, c = getc(stdin);
  while (c <= 32) c = getc(stdin);
  if (c == '-') s = -1, c = getc(stdin);
  while ('0' <= c && c <= '9') x = x * 10 + c - '0', c = getc(stdin);
  return x * s;
}
template <typename T>
inline T gcd(T a, T b) {
  while (a && b) a > b ? a %= b : b %= a;
  return a + b;
}
inline bool Palindrome(const string& s) {
  return equal(s.begin(), s.end(), s.rbegin());
}
string f = "face";
char s[100][100];
int res;
int main() {
  int n = nextInt(), m = nextInt();
  for (int i = 0; i < n; ++i) {
    gets(s[i]);
  }
  for (int i = 0; i + 1 < n; ++i) {
    for (int j = 0; j + 1 < m; ++j) {
      string t;
      t += s[i][j];
      t += s[i + 1][j];
      t += s[i][j + 1];
      t += s[i + 1][j + 1];
      sort(t.begin(), t.end());
      do {
        res += t == f;
      } while (next_permutation(t.begin(), t.end()));
    }
  }
  printf("%d", res);
  return 0;
}
