#include <bits/stdc++.h>
using namespace std;
const int SIZE = 77;
char board[SIZE][SIZE];
int n, m;
int main() {
  while (cin >> n >> m) {
    memset(board, 0, sizeof(board));
    for (int i = 0; i < n; i++) {
      cin >> board[i];
    }
    int ans = 0;
    for (int i = 0; i + 1 < n; i++) {
      for (int j = 0; j + 1 < m; j++) {
        string f = string() + board[i][j] + board[i][j + 1] + board[i + 1][j] +
                   board[i + 1][j + 1];
        sort(f.begin(), f.end());
        if (f == "acef") {
          ans++;
        }
      }
    }
    cout << ans << endl;
  }
  return 0;
}
