#include <bits/stdc++.h>
using namespace std;
int n, m;
char s[101][101];
bool mk(char s1, char s2, char s3, char s4) {
  int cnt0 = 0, cnt1 = 0, cnt2 = 0, cnt3 = 0;
  if (s1 == 'f' || s2 == 'f' || s3 == 'f' || s4 == 'f') cnt0++;
  if (s1 == 'a' || s2 == 'a' || s3 == 'a' || s4 == 'a') cnt1++;
  if (s1 == 'c' || s2 == 'c' || s3 == 'c' || s4 == 'c') cnt2++;
  if (s1 == 'e' || s2 == 'e' || s3 == 'e' || s4 == 'e') cnt3++;
  return (cnt0 * cnt1 * cnt2 * cnt3 == 1);
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 0; i < n; i++) scanf("%s", s[i]);
  int ans = 0;
  for (int i = 0; i < n - 1; i++)
    for (int j = 0; j < m - 1; j++) {
      if (mk(s[i][j], s[i][j + 1], s[i + 1][j], s[i + 1][j + 1])) ans++;
    }
  printf("%d\n", ans);
  return 0;
}
