#include <bits/stdc++.h>
using namespace std;
const int maxn = 55;
char a[maxn][maxn];
int main() {
  int n, m;
  while (cin >> n >> m) {
    for (int i = 0; i < n; i++) scanf("%s", a[i]);
    int ans = 0;
    for (int i = 1; i < n; i++) {
      for (int j = 1; j < m; j++) {
        int tmp[6] = {0};
        for (int k = i - 1; k <= i; k++)
          for (int l = j - 1; l <= j; l++) switch (a[k][l]) {
              case 'a':
                tmp[0]++;
                break;
              case 'c':
                tmp[1]++;
                break;
              case 'e':
                tmp[2]++;
                break;
              case 'f':
                tmp[3]++;
                break;
            }
        int cnt = 0;
        while (tmp[cnt] > 0) cnt++;
        if (cnt >= 4) ans++;
      }
    }
    cout << ans << endl;
  }
  return 0;
}
