#include <bits/stdc++.h>
using namespace std;
string a[60];
int main() {
  int n, m, sh = 0;
  ;
  cin >> n >> m;
  for (int i = 0; i < n; i++) cin >> a[i];
  for (int i = 0; i < n - 1; i++)
    for (int j = 0; j < m - 1; j++) {
      if ((a[i][j] == 'f' || a[i + 1][j] == 'f' || a[i][j + 1] == 'f' ||
           a[i + 1][j + 1] == 'f') &&
          (a[i][j] == 'a' || a[i + 1][j] == 'a' || a[i][j + 1] == 'a' ||
           a[i + 1][j + 1] == 'a') &&
          (a[i][j] == 'c' || a[i + 1][j] == 'c' || a[i][j + 1] == 'c' ||
           a[i + 1][j + 1] == 'c') &&
          (a[i][j] == 'e' || a[i + 1][j] == 'e' || a[i][j + 1] == 'e' ||
           a[i + 1][j + 1] == 'e'))
        sh++;
    }
  cout << sh;
  return 0;
}
