#include <bits/stdc++.h>
using namespace std;
char a[52][52];
int i, j;
int answ;
int n, m;
int main() {
  cin >> n >> m;
  for (i = 1; i <= n; i++)
    for (j = 1; j <= m; j++) {
      cin >> a[i][j];
    }
  for (i = 1; i < n; i++)
    for (j = 1; j < m; j++) {
      bool mark[12];
      mark[1] = mark[2] = mark[3] = mark[4] = false;
      if (a[i][j] == 'f' || a[i][j + 1] == 'f' || a[i + 1][j] == 'f' ||
          a[i + 1][j + 1] == 'f')
        mark[1] = true;
      if (a[i][j] == 'a' || a[i][j + 1] == 'a' || a[i + 1][j] == 'a' ||
          a[i + 1][j + 1] == 'a')
        mark[2] = true;
      if (a[i][j] == 'c' || a[i][j + 1] == 'c' || a[i + 1][j] == 'c' ||
          a[i + 1][j + 1] == 'c')
        mark[3] = true;
      if (a[i][j] == 'e' || a[i][j + 1] == 'e' || a[i + 1][j] == 'e' ||
          a[i + 1][j + 1] == 'e')
        mark[4] = true;
      if (mark[1] && mark[2] && mark[3] && mark[4]) answ++;
    }
  cout << answ << endl;
  return 0;
}
