#include <bits/stdc++.h>
using namespace std;
char ch[55][55];
int main() {
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++) cin >> ch[i][j];
  int ret = 0;
  for (int i = 0; i < n - 1; i++)
    for (int j = 0; j < m - 1; j++) {
      bool f = 0, a = 0, c = 0, e = 0;
      for (int h = i; h < i + 2; h++)
        for (int k = j; k < j + 2; k++)
          if (ch[h][k] == 'f')
            f = 1;
          else if (ch[h][k] == 'a')
            a = 1;
          else if (ch[h][k] == 'c')
            c = 1;
          else if (ch[h][k] == 'e')
            e = 1;
      if (f && a && c && e) ret++;
    }
  cout << ret << endl;
}
