#include <bits/stdc++.h>
using namespace std;
int n, m, b[5], ans;
char c[55][55];
int main() {
  cin >> n >> m;
  for (int i = 1; i <= n; i++) scanf("%s", c[i] + 1);
  for (int i = 1; i < n; i++)
    for (int j = 1; j < m; j++) {
      memset(b, 0, sizeof(b));
      for (int ii = 0; ii <= 1; ii++)
        for (int jj = 0; jj <= 1; jj++) {
          if (c[i + ii][j + jj] == 'f')
            b[1] = 1;
          else if (c[i + ii][j + jj] == 'a')
            b[2] = 1;
          else if (c[i + ii][j + jj] == 'c')
            b[3] = 1;
          else if (c[i + ii][j + jj] == 'e')
            b[4] = 1;
        }
      if (b[1] && b[2] && b[3] && b[4]) ans++;
    }
  cout << ans << endl;
  return 0;
}
