#include <bits/stdc++.h>
using namespace std;
const int maxn = 5 * 12;
int n, m;
char ch[maxn];
int ai[maxn][maxn];
void init() {
  memset(ai, 0, sizeof(ai));
  for (int i = 1; i <= n; i++) {
    scanf("%s", ch + 1);
    for (int j = 1; j <= m; j++) {
      if (ch[j] == 'f')
        ai[i][j] = 1;
      else if (ch[j] == 'a')
        ai[i][j] = 2;
      else if (ch[j] == 'c')
        ai[i][j] = 3;
      else if (ch[j] == 'e')
        ai[i][j] = 4;
    }
  }
}
int bi[5];
void play() {
  int sum = 0;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      int t1 = ai[i][j];
      int t2 = ai[i][j + 1];
      int t3 = ai[i + 1][j];
      int t4 = ai[i + 1][j + 1];
      bi[1] = bi[2] = bi[3] = bi[4] = 0;
      bi[t1]++;
      bi[t2]++;
      bi[t3]++;
      bi[t4]++;
      if (bi[1] == 1 && bi[2] == 1 && bi[3] == 1 && bi[4] == 1) sum++;
    }
  }
  printf("%d\n", sum);
}
int main() {
  while (scanf("%d%d", &n, &m) != EOF) {
    init();
    play();
  }
  return 0;
}
