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