#include <bits/stdc++.h>
char a[51][51];
char d[4] = {'f', 'a', 'c', 'e'};
int DT[50][50];
int n, m;
int cnt;
int dx[4] = {0, 1, 0, 1};
int dy[4] = {0, 0, 1, 1};
int f(int x, int y) {
  int ret = 0;
  for (int i = 0; i < 4; i++) {
    for (int j = 0; j < 4; j++) {
      if (a[x + dx[i]][y + dy[i]] == d[j]) {
        ret += 1 << j;
      }
    }
  }
  return ret;
}
int main() {
  scanf("%d %d", &n, &m);
  for (int i = 0; i < n; i++) {
    scanf("%s", a[i]);
  }
  for (int i = 0; i < n - 1; i++) {
    for (int j = 0; j < m - 1; j++) {
      for (int k = 0; k < 4; k++) {
        if (a[i][j] == d[k]) {
          DT[i][j] = f(i, j);
          if (DT[i][j] == 15) {
            cnt++;
          }
        }
      }
    }
  }
  printf("%d", cnt);
}
