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