#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, m;
  cin >> n >> m;
  map<char, long long> ok;
  char a[n][m];
  ok['f'] = 1;
  ok['a'] = 1;
  ok['c'] = 1;
  ok['e'] = 1;
  for (long long i = 0; i < n; i++) {
    for (long long j = 0; j < m; j++) {
      cin >> a[i][j];
    }
  }
  string theans = "";
  long long cnt = 0;
  for (long long i = 0; i < n - 1; i++) {
    for (long long j = 0; j < m - 1; j++) {
      theans = a[i][j];
      theans += a[i][j + 1];
      theans += a[i + 1][j];
      theans += a[i + 1][j + 1];
      for (long long i = 0; i < 4; i++) {
        for (long long j = i + 1; j < 4; j++)
          if (theans[i] > theans[j]) swap(theans[i], theans[j]);
      }
      if (theans == "acef") cnt++;
    }
  }
  cout << cnt;
}
