#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  scanf("%d", &n);
  scanf("%d", &m);
  cin.get();
  char image[n][m];
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) scanf("%c", &image[i][j]);
    cin.get();
  }
  char check[4];
  int count = 0;
  if (n >= 2 && m >= 2) {
    for (int i = 0; i < n - 1; i++) {
      for (int j = 0; j < m - 1; j++) {
        check[0] = image[i][j];
        check[1] = image[i][j + 1];
        check[2] = image[i + 1][j];
        check[3] = image[i + 1][j + 1];
        sort(check, check + 4);
        if (check[0] == 'a' && check[1] == 'c' && check[2] == 'e' &&
            check[3] == 'f')
          count++;
      }
    }
  }
  printf("%d", count);
}
