#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  vector<vector<char>> image;
  image.resize(n);
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      char x;
      cin >> x;
      image.at(i).push_back(x);
    }
  }
  int count = 0;
  for (int i = 0; i < n - 1; i++) {
    for (int j = 0; j < m - 1; j++) {
      bool f = false;
      bool a = false;
      bool c = false;
      bool e = false;
      if (image.at(i).at(j) == 'f') f = true;
      if (image.at(i).at(j) == 'a') a = true;
      if (image.at(i).at(j) == 'c') c = true;
      if (image.at(i).at(j) == 'e') e = true;
      if (image.at(i + 1).at(j) == 'f') f = true;
      if (image.at(i + 1).at(j) == 'a') a = true;
      if (image.at(i + 1).at(j) == 'c') c = true;
      if (image.at(i + 1).at(j) == 'e') e = true;
      if (image.at(i).at(j + 1) == 'f') f = true;
      if (image.at(i).at(j + 1) == 'a') a = true;
      if (image.at(i).at(j + 1) == 'c') c = true;
      if (image.at(i).at(j + 1) == 'e') e = true;
      if (image.at(i + 1).at(j + 1) == 'f') f = true;
      if (image.at(i + 1).at(j + 1) == 'a') a = true;
      if (image.at(i + 1).at(j + 1) == 'c') c = true;
      if (image.at(i + 1).at(j + 1) == 'e') e = true;
      if (f && a && c && e) count++;
    }
  }
  cout << count;
}
