#include <bits/stdc++.h>
using namespace std;
const int MAXN = 50 + 5;
char a[MAXN][MAXN];
int num[500];
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  for (int i = 0; i < n; ++i)
    for (int j = 0; j < m; ++j) cin >> a[i][j];
  int res = 0;
  for (int i = 0; i + 1 < n; ++i) {
    for (int j = 0; j + 1 < m; ++j) {
      memset(num, 0, sizeof(num));
      for (int r = 0; r <= 1; ++r)
        for (int s = 0; s <= 1; ++s) num[a[i + r][j + s]] = 1;
      if (num['a'] + num['f'] + num['c'] + num['e'] == 4) ++res;
    }
  }
  cout << res << endl;
}
