#include <bits/stdc++.h>
using namespace std;
char mm[66][66];
int f(char x) {
  if (x == 'f') return 0;
  if (x == 'a') return 1;
  if (x == 'c') return 2;
  if (x == 'e') return 3;
  return 4;
}
int ck(int x, int y) {
  int vis[5] = {0};
  for (int i = x; i < x + 2; ++i) {
    for (int j = y; j < y + 2; ++j) {
      vis[f(mm[i][j])] = 1;
    }
  }
  int ans = 0;
  for (int i = 0; i < 4; ++i) {
    if (vis[i]) ans++;
  }
  return ans == 4 ? 1 : 0;
}
int main() {
  int n, m;
  while (scanf("%d%d", &n, &m) != EOF) {
    for (int i = 0; i < n; ++i) scanf("%s", mm[i]);
    int ans = 0;
    for (int i = 0; i < n - 1; ++i) {
      for (int j = 0; j < m - 1; ++j) {
        if (ck(i, j)) ans++;
      }
    }
    printf("%d\n", ans);
  }
}
