#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  char a[53][53] = {5};
  int ans = 0;
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++) {
      char x;
      cin >> x;
      if (x == 'a' || x == 'f' || x == 'c' || x == 'e') a[i][j] = x;
    }
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++) {
      string c = "";
      c += a[i][j];
      c += a[i][j + 1];
      c += a[i + 1][j];
      c += a[i + 1][j + 1];
      sort(c.begin(), c.end());
      if (c == "acef") ans += 1;
    }
  cout << ans;
  return 0;
}
