#include <bits/stdc++.h>
using namespace std;
vector<string> split(const string &s, char c) {
  vector<string> v;
  stringstream ss(s);
  string x;
  while (getline(ss, x, c)) v.push_back(x);
  return v;
}
void err(vector<string>::iterator it) {}
template <typename T, typename... Args>
void err(vector<string>::iterator it, T a, Args... args) {
  cerr << it->substr((*it)[0] == ' ', it->length()) << " = " << a << '\n';
  err(++it, args...);
}
const int MOD = 1000000007;
template <class T>
inline T tmin(T a, T b) {
  return (a < b) ? a : b;
}
template <class T>
inline T tmax(T a, T b) {
  return (a > b) ? a : b;
}
template <class T>
inline void amax(T &a, T b) {
  if (b > a) a = b;
}
template <class T>
inline void amin(T &a, T b) {
  if (b < a) a = b;
}
template <class T>
inline T tabs(T a) {
  return (a > 0) ? a : -a;
}
template <class T>
T gcd(T a, T b) {
  while (b != 0) {
    T c = a;
    a = b;
    b = c % b;
  }
  return a;
}
const int N = 55;
char s[N][N];
int main(int argc, char *argv[]) {
  ios_base::sync_with_stdio(false);
  int n, m;
  cin >> n >> m;
  for (int i = (0); i < (n); ++i) cin >> s[i];
  int ret = 0;
  for (int i = (0); i < (n - 1); ++i)
    for (int j = (0); j < (m - 1); ++j) {
      string face = "";
      for (int x = (0); x < (2); ++x)
        for (int y = (0); y < (2); ++y) face += s[i + x][j + y];
      sort(face.begin(), face.end());
      if (face == "acef") ret++;
    }
  printf("%d\n", ret);
  return 0;
}
