#include <bits/stdc++.h>
int main(void) {
  int n, m, c1 = 0, c2 = 0, c3 = 0, c4 = 0, count = 0, i, j;
  scanf("%d%d\n", &n, &m);
  char s[n + 1][m + 1];
  for (i = 0; i < n; i++) {
    for (j = 0; j < m; j++) scanf("%c\n", &s[i][j]);
  }
  for (i = 0; i < n - 1; i++) {
    for (j = 0; j < m - 1; j++) {
      if (s[i][j] == 'f')
        c1++;
      else if (s[i][j] == 'a')
        c2++;
      else if (s[i][j] == 'c')
        c3++;
      else if (s[i][j] == 'e')
        c4++;
      if (s[i][j + 1] == 'f')
        c1++;
      else if (s[i][j + 1] == 'a')
        c2++;
      else if (s[i][j + 1] == 'c')
        c3++;
      else if (s[i][j + 1] == 'e')
        c4++;
      if (s[i + 1][j] == 'f')
        c1++;
      else if (s[i + 1][j] == 'a')
        c2++;
      else if (s[i + 1][j] == 'c')
        c3++;
      else if (s[i + 1][j] == 'e')
        c4++;
      if (s[i + 1][j + 1] == 'f')
        c1++;
      else if (s[i + 1][j + 1] == 'a')
        c2++;
      else if (s[i + 1][j + 1] == 'c')
        c3++;
      else if (s[i + 1][j + 1] == 'e')
        c4++;
      if (c1 == 1 && c2 == 1 && c3 == 1 && c4 == 1) count++;
      c1 = c2 = c3 = c4 = 0;
    }
  }
  printf("%d\n", count);
  return 0;
}
