#include <bits/stdc++.h>
using namespace std;
char s[555][555];
bool ok(int x, int y) {
  bool c[555];
  c['f'] = c['a'] = c['c'] = c['e'] = 0;
  for (int i = 0; i < 2; ++i)
    for (int j = 0; j < 2; ++j) c[s[i + x][j + y]] = 1;
  return c['f'] && c['a'] && c['c'] && c['e'];
}
int main(void) {
  int n, m;
  cin >> n >> m;
  int ans = 0;
  for (int i = 1; i <= n; ++i) cin >> (s[i] + 1);
  for (int i = 1; i < n; ++i)
    for (int j = 1; j < m; ++j) ans += ok(i, j);
  return cout << ans << '\n', 0;
}
