#include <bits/stdc++.h>
using namespace std;
map<char, bool> h;
char mat[99][99];
vector<char> sol;
inline int check(int i, int j) {
  h.clear();
  sol.clear();
  sol.push_back(mat[i - 1][j]);
  sol.push_back(mat[i - 1][j - 1]);
  sol.push_back(mat[i][j - 1]);
  sol.push_back(mat[i][j]);
  for (auto x : sol) h[x] = 1;
  if (h['f'] and h['a'] and h['c'] and h['e']) return 1;
  return 0;
}
int main(void) {
  ios ::sync_with_stdio(false);
  int n, m, CET = 0;
  cin >> n >> m;
  for (int i = 1; i <= n; ++i)
    for (int j = 1; j <= m; ++j) cin >> mat[i][j];
  for (int i = 1; i <= n; ++i)
    for (int j = 1; j <= m; ++j) CET += check(i, j);
  cout << CET << '\n';
  return 0;
}
