#include <bits/stdc++.h>
char ch[4];
char st[55][55];
int m, n, i, j, k, l, x, y, c;
int main() {
  scanf("%d %d", &m, &n);
  for (i = 0; i < m; i++) scanf("%s", st[i]);
  c = 0;
  for (i = 0; i < m - 1; i++) {
    for (j = 0; j < n - 1; j++) {
      for (k = 0; k < 4; k++) ch[k] = 0;
      for (k = 0; k <= 1; k++) {
        for (l = 0; l <= 1; l++) {
          if (st[i + k][j + l] == 'f') ch[0] = 1;
          if (st[i + k][j + l] == 'a') ch[1] = 1;
          if (st[i + k][j + l] == 'c') ch[2] = 1;
          if (st[i + k][j + l] == 'e') ch[3] = 1;
        }
      }
      if (ch[0] == 0 || ch[1] == 0 || ch[2] == 0 || ch[3] == 0)
        ;
      else
        c++;
    }
  }
  printf("%d\n", c);
}
