#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  long long int res = 0;
  string S[n];
  for (int i = 0; i < n; i++) cin >> S[i];
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (S[i][j] == 'f') {
        if ((i + 1) < n && (j + 1) < m) {
          vector<int> C;
          C.push_back(S[i][j + 1]);
          C.push_back(S[i + 1][j + 1]);
          C.push_back(S[i + 1][j]);
          sort(C.begin(), C.end());
          if (C[0] == 97 && C[1] == 99 && C[2] == 101) res++;
        }
        if ((i + 1) < n && (j - 1) >= 0) {
          vector<int> C;
          C.push_back(S[i][j - 1]);
          C.push_back(S[i + 1][j - 1]);
          C.push_back(S[i + 1][j]);
          sort(C.begin(), C.end());
          if (C[0] == 97 && C[1] == 99 && C[2] == 101) res++;
        }
        if ((i - 1) >= 0 && (j + 1) < m) {
          vector<int> C;
          C.push_back(S[i][j + 1]);
          C.push_back(S[i - 1][j + 1]);
          C.push_back(S[i - 1][j]);
          sort(C.begin(), C.end());
          if (C[0] == 97 && C[1] == 99 && C[2] == 101) res++;
        }
        if ((i - 1) >= 0 && (j - 1) < m) {
          vector<int> C;
          C.push_back(S[i][j - 1]);
          C.push_back(S[i - 1][j - 1]);
          C.push_back(S[i - 1][j]);
          sort(C.begin(), C.end());
          if (C[0] == 97 && C[1] == 99 && C[2] == 101) res++;
        }
      }
    }
  }
  cout << res << endl;
  return 0;
}
