#include <bits/stdc++.h>
using namespace std;
const int MAXN = 100;
long long a[MAXN], b[MAXN];
long long n, y, z, t, m, f, x, d, k, l, c;
string s[MAXN], s1, s2;
bool mark[MAXN], io = false;
vector<int> v[MAXN];
set<int> st;
pair<int, int> p1[MAXN], p2[MAXN];
char g1, g2, g3, g4;
int main() {
  cin >> n >> m;
  s1 = "face";
  sort(s1.begin(), s1.end());
  for (int i = 0; i < n; i++) {
    cin >> s[i];
  }
  for (int i = 0; i < n - 1; i++) {
    for (int j = 0; j < m - 1; j++) {
      string s2 = "";
      s2 += s[i][j];
      s2 += s[i + 1][j];
      s2 += s[i][j + 1];
      s2 += s[i + 1][j + 1];
      sort(s2.begin(), s2.end());
      if (s1 == s2) x++;
    }
  }
  cout << x;
  return 0;
}
