#include <bits/stdc++.h>
int main() {
  int i, j, k, p, t, m, n, number = 0;
  int temp[4];
  char *ptr = (char *)malloc(50 * 50 * sizeof(char));
  char **mass = (char **)malloc(50 * sizeof(char *));
  for (i = 0; i < 50; i++) mass[i] = &ptr[i * 50];
  scanf("%d%d", &n, &m);
  for (gets(ptr), i = 0; i < n; i++) {
    for (j = 0; j < m; j++) mass[i][j] = getchar();
    getchar();
  }
  for (n--, m--, i = 0; i < n; i++) {
    for (j = 0; j < m; j++) {
      for (k = 0; k < 4; temp[k] = 0, k++)
        ;
      for (p = 0; p < 2; p++) {
        for (t = 0; t < 2; t++) {
          switch (mass[i + p][j + t]) {
            case 'f':
              temp[0]++;
              break;
            case 'a':
              temp[1]++;
              break;
            case 'c':
              temp[2]++;
              break;
            case 'e':
              temp[3]++;
              break;
          }
        }
      }
      for (k = 0; k < 4 && temp[k]; k++)
        ;
      if (k == 4) number++;
    }
  }
  printf("%d", number);
  free(mass);
  free(ptr);
  return 0;
}
