#include <bits/stdc++.h>
using namespace std;
int main() {
  int x, y, z = 0, i, t;
  char a[60][60];
  cin >> x >> y;
  for (i = 1; i <= x; i++)
    for (t = 1; t <= y; t++) cin >> a[i][t];
  for (i = 1; i < x; i++)
    for (t = 1; t < y; t++) {
      set<char> s;
      if (a[i][t] == 'f' || a[i][t] == 'a' || a[i][t] == 'c' || a[i][t] == 'e')
        s.insert(a[i][t]);
      if (a[i + 1][t] == 'f' || a[i + 1][t] == 'a' || a[i + 1][t] == 'c' ||
          a[i + 1][t] == 'e')
        s.insert(a[i + 1][t]);
      if (a[i + 1][t + 1] == 'f' || a[i + 1][t + 1] == 'a' ||
          a[i + 1][t + 1] == 'c' || a[i + 1][t + 1] == 'e')
        s.insert(a[i + 1][t + 1]);
      if (a[i][t + 1] == 'f' || a[i][t + 1] == 'a' || a[i][t + 1] == 'c' ||
          a[i][t + 1] == 'e')
        s.insert(a[i][t + 1]);
      if (s.size() == 4) z++;
    }
  cout << z << endl;
  return 0;
}
