#include <bits/stdc++.h>
using namespace std;
int main() {
  long long i, j, k, n, m;
  cin >> n >> m;
  getchar();
  long long ans = 0;
  char a[100][100];
  if (n >= 2 && m >= 2) {
    for (i = 0; i < n; i++) {
      for (j = 0; j < m; j++) {
        char c = getchar();
        a[i][j] = c;
      }
      getchar();
    }
    for (i = 0; i < n - 1; i++) {
      for (j = 0; j < m - 1; j++) {
        int f[26] = {0};
        f[a[i][j] - 'a']++;
        f[a[i + 1][j] - 'a']++;
        f[a[i][j + 1] - 'a']++;
        f[a[i + 1][j + 1] - 'a']++;
        if (f['f' - 'a'] == 1 && f[0] == 1 && f[2] == 1 && f[4] == 1) ans++;
      }
    }
  }
  cout << ans << endl;
  return 0;
}
