#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  int **a = new int *[n];
  for (int i = 0; i < n; i++) {
    a[i] = new int[m]{};
  }
  if (n == 1 || m == 1) {
    cout << 0;
  } else {
    string s;
    int ans = 0;
    for (int i = 0; i < n; i++) {
      cin >> s;
      for (int j = 0; j < m; j++) {
        if (s[j] != 'x') {
          switch (s[j]) {
            case 'f':
              a[i][j] = 1;
              break;
            case 'a':
              a[i][j] = 10;
              break;
            case 'c':
              a[i][j] = 100;
              break;
            case 'e':
              a[i][j] = 1000;
            default:
              break;
          }
          if (i > 0) {
            if (a[i][j] + a[i][j - 1] + a[i - 1][j] + a[i - 1][j - 1] == 1111) {
              ans++;
            }
          }
        }
      }
    }
    cout << ans;
  }
}
