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