#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m, z = 0;
  char asd[50][50];
  cin >> n >> m;
  map<char, int> asd1;
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++) cin >> asd[i][j];
  for (int i = 0; i < n - 1; i++) {
    for (int j = 0; j < m - 1; j++) {
      asd1[asd[i][j]]++;
      asd1[asd[i][j + 1]]++;
      asd1[asd[i + 1][j]]++;
      asd1[asd[i + 1][j + 1]]++;
      if (asd1['f'] == 1 && asd1['a'] == 1 && asd1['c'] == 1 && asd1['e'] == 1)
        z++;
      asd1.clear();
    }
  }
  cout << z << endl;
  return 0;
}
