#include <bits/stdc++.h>
using namespace std;
string a[55];
bool check(int i, int j) {
  bool f = false;
  bool aq = false;
  bool c = false;
  bool e = false;
  for (int i1 = i; i1 <= i + 1; ++i1) {
    for (int j1 = j; j1 <= j + 1; ++j1) {
      if (a[i1][j1] == 'f') f = true;
      if (a[i1][j1] == 'a') aq = true;
      if (a[i1][j1] == 'c') c = true;
      if (a[i1][j1] == 'e') e = true;
    }
  }
  return (f && aq && c && e);
}
int main() {
  int ans = 0;
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < n; ++i) cin >> a[i];
  if (n < 2 || m < 2) {
    cout << 0;
    return 0;
  }
  for (int i = 0; i < n - 1; ++i) {
    for (int j = 0; j < m - 1; ++j) {
      if (check(i, j)) ++ans;
    }
  }
  cout << ans;
  return 0;
}
