#include <bits/stdc++.h>
using namespace std;
const int mod = (int)(1e9 + 7);
vector<int> read(int n) {
  vector<int> v(n);
  for (int i = 0; i < n; i++) cin >> v[i];
  return v;
}
void solve() {
  long long int i, j, k, m, n, ans = 0, cnt = 0, sum = 0;
  cin >> n >> m;
  char a[n][m];
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++) cin >> a[i][j];
  long long int F = 0, A = 0, c = 0, e = 0;
  for (long long int i = 0; i <= n - 2; i++) {
    for (long long int j = 0; j <= m - 2; j++) {
      if (a[i][j] == 'a' || a[i][j] == 'f' || a[i][j] == 'c' ||
          a[i][j] == 'e') {
        for (long long int k = i; k <= i + 1; k++) {
          for (long long int f = j; f <= j + 1; f++) {
            if (a[k][f] == 'f') F++;
            if (a[k][f] == 'a') A++;
            if (a[k][f] == 'c') c++;
            if (a[k][f] == 'e') e++;
          }
        }
        if (F && A && c && e) ans++;
        F = 0, A = 0, c = 0, e = 0;
      }
    }
  }
  cout << ans << "\n";
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  solve();
  return 0;
}
