#include <bits/stdc++.h>
using namespace std;
int main() {
  int m, n;
  cin >> m >> n;
  string temp;
  getline(cin, temp);
  vector<string> image;
  while (getline(cin, temp)) {
    image.push_back(temp);
  }
  int numFaces = 0;
  int argh[26];
  for (int i = 0; i < 26; i++) {
    argh[i] = 0;
  }
  for (int i = 0; i + 1 < m; i++) {
    for (int j = 0; j + 1 < n; j++) {
      char ul = image[i][j];
      argh[ul - 'a']++;
      char ur = image[i][j + 1];
      argh[ur - 'a']++;
      char ll = image[i + 1][j];
      argh[ll - 'a']++;
      char lr = image[i + 1][j + 1];
      argh[lr - 'a']++;
      if (argh[5] == 1 && argh[0] == 1 && argh[2] == 1 && argh[4] == 1) {
        numFaces++;
      }
      argh[ul - 'a'] = 0;
      argh[ur - 'a'] = 0;
      argh[ll - 'a'] = 0;
      argh[lr - 'a'] = 0;
    }
  }
  cout << numFaces << endl;
}
